@@ -25,17 +25,55 @@ export default function Index() {
2525 useEffect ( ( ) => {
2626 console . log ( 'Setting up realtime connection...' )
2727 console . log ( 'Realtime URL:' , supabase . realtime . endPoint )
28+ console . log ( 'Realtime client:' , supabase . realtime )
2829
29- const channel = supabase . channel ( 'realtime:public:todos' )
30+ // Check if we can access the WebSocket connection
31+ try {
32+ console . log ( 'Realtime client properties:' , Object . keys ( supabase . realtime ) )
33+ console . log (
34+ 'Realtime client methods:' ,
35+ Object . getOwnPropertyNames ( Object . getPrototypeOf ( supabase . realtime ) )
36+ )
37+ } catch ( error ) {
38+ console . log ( 'Error accessing realtime client properties:' , error )
39+ }
40+
41+ // Use a simpler channel name for testing
42+ const channel = supabase . channel ( 'test-channel' )
43+
44+ console . log ( 'Created channel:' , channel )
45+ console . log ( 'Channel state:' , channel . state )
46+
47+ const subscription = channel . subscribe ( ( status ) => {
48+ console . log ( 'Realtime status callback received:' , status )
49+ console . log ( 'Channel state after status:' , channel . state )
50+ console . log ( 'Channel topic:' , channel . topic )
3051
31- channel . subscribe ( ( status ) => {
32- console . log ( 'Realtime status:' , status )
3352 // Show all statuses, not just SUBSCRIBED
3453 setRealtimeStatus ( status )
3554 } )
3655
56+ console . log ( 'Subscription result:' , subscription )
57+
58+ // Add a timeout to check if we're stuck
59+ const timeoutId = setTimeout ( ( ) => {
60+ console . log ( 'Timeout check - Current realtime status:' , realtimeStatus )
61+ console . log ( 'Timeout check - Channel state:' , channel . state )
62+ console . log ( 'Timeout check - Channel topic:' , channel . topic )
63+
64+ // Try to manually check the connection
65+ try {
66+ console . log ( 'Attempting to check realtime connection manually...' )
67+ // This might help us understand what's happening
68+ console . log ( 'All channels:' , supabase . getChannels ( ) )
69+ } catch ( error ) {
70+ console . log ( 'Error checking channels:' , error )
71+ }
72+ } , 5000 )
73+
3774 return ( ) => {
3875 console . log ( 'Cleaning up realtime connection...' )
76+ clearTimeout ( timeoutId )
3977 channel . unsubscribe ( )
4078 supabase . realtime . disconnect ( )
4179 }
0 commit comments