Skip to content

Conversation

@cj-vana
Copy link
Collaborator

@cj-vana cj-vana commented Oct 10, 2025

User description

…wer"

This reverts commit 977c101.


PR Type

Other


Description

  • Reverts automatic WebSocket reconnection feature for Run of Show viewer

  • Removes complex realtime subscription hook with retry logic

  • Simplifies connection status UI to basic legend only

  • Returns to basic Supabase realtime subscription implementation


Diagram Walkthrough

flowchart LR
  A["Complex Realtime Hook"] -- "revert" --> B["Basic Supabase Subscription"]
  C["Connection Status UI"] -- "simplify" --> D["Basic Legend"]
  E["Retry Logic"] -- "remove" --> F["Simple Error Handling"]
Loading

File Walkthrough

Relevant files
Other
useRealtimeSubscription.ts
Remove entire realtime subscription hook file                       

apps/web/src/hooks/useRealtimeSubscription.ts

  • Completely removes the entire file containing the realtime
    subscription hook
  • Eliminates 249 lines of code including connection management and retry
    logic
  • Removes TypeScript interfaces and types for connection status
+0/-249 
SharedShowModePage.tsx
Revert to basic Supabase realtime subscription                     

apps/web/src/pages/SharedShowModePage.tsx

  • Removes import of useRealtimeSubscription hook and related icons
  • Replaces complex hook usage with basic Supabase channel subscription
  • Simplifies connection status UI by removing live connection indicators
  • Removes retry button and connection status display logic
+48/-75 

@netlify
Copy link

netlify bot commented Oct 10, 2025

Deploy Preview for sounddocsbeta ready!

Name Link
🔨 Latest commit cc8fc3f
🔍 Latest deploy log https://app.netlify.com/projects/sounddocsbeta/deploys/68e957fb48aea30008509922
😎 Deploy Preview https://deploy-preview-115--sounddocsbeta.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cj-vana cj-vana merged commit d43679a into beta Oct 10, 2025
4 of 5 checks passed
@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
Resource exhaustion risk

Description: On subscription error or timeout, the code sets a generic error message but does not
attempt cleanup or throttling, which could allow repeated subscribe/unsubscribe cycles
elsewhere to cause resource exhaustion; consider ensuring single subscription and guarding
against duplicate channels.
SharedShowModePage.tsx [116-124]

Referred Code
.subscribe((status, err) => {
  if (status === "SUBSCRIBED") {
    console.log("Subscribed to real-time updates for Run of Show ID:", sharedData.id);
  }
  if (status === "CHANNEL_ERROR" || status === "TIMED_OUT") {
    console.error("Real-time subscription error:", status, err);
    setError("Connection lost. Please refresh to see live updates.");
  }
});
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix infinite loop in useEffect

Change the useEffect dependency from sharedData to sharedData?.id to prevent an
infinite loop of unsubscribing and re-subscribing to real-time updates.

apps/web/src/pages/SharedShowModePage.tsx [89-129]

 useEffect(() => {
   if (!sharedData || !sharedData.id) return;
 
   const channel = supabase
     .channel(`public:run_of_shows:id=eq.${sharedData.id}`)
     .on(
       "postgres_changes",
       {
         event: "UPDATE",
         schema: "public",
         table: "run_of_shows",
         filter: `id=eq.${sharedData.id}`,
       },
       (payload) => {
         console.log("Real-time update received:", payload);
         const updatedRunOfShow = payload.new as SharedRunOfShowData;
         setSharedData((prevData) => {
           if (!prevData) return null;
           return {
             ...prevData,
             live_show_data: updatedRunOfShow.live_show_data,
             items: updatedRunOfShow.items || prevData.items,
             last_edited: updatedRunOfShow.last_edited || prevData.last_edited,
           };
         });
       },
     )
     .subscribe((status, err) => {
       if (status === "SUBSCRIBED") {
         console.log("Subscribed to real-time updates for Run of Show ID:", sharedData.id);
       }
       if (status === "CHANNEL_ERROR" || status === "TIMED_OUT") {
         console.error("Real-time subscription error:", status, err);
         setError("Connection lost. Please refresh to see live updates.");
       }
     });
 
   return () => {
     supabase.removeChannel(channel);
   };
-}, [sharedData]);
+}, [sharedData?.id]);

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a critical bug that creates an infinite loop of subscriptions and unsubscriptions, and the proposed fix of changing the dependency array is the correct solution.

High
  • More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant