Help with real-time subscription in React
# javascript
m
Help with real-time subscription in React
Hey guys need a bit of help on the implementation of real time subscription. Currently I have this code inside one of my React pages:
Copy code
js
useEffect(() => { 
        GameServices.getPerson(setAdmin)
        GameServices.getTeams(setTeams);
        GameServices.getTime(setTime);
        supabaseClient
            .from('*')
            .on('*', payload => {
                console.log('Change received!', payload)
                GameServices.getTeams(setTeams);
                GameServices.getTime(setTime);
                console.log('Change received!', payload)
        }).subscribe((status)=>{console.log('subscribe',status);})
    },[]);
On the console I can see that the subscription status is SUBSCRIBED, and I currently have Replication enabled for all events and for all tables in my DB. I'm also using RLS policies.
g
Make sure you are on the latest supabase.js 1.28.5
m
yes its updated
g
Any changes to tables with RLS on will only come thru as changed if the user has RLS permission to do that operation also. That said there are some issues being worked by Supabase on the new realtime with RLS. This is the main thread. https://github.com/supabase/supabase/issues/4201
m
Thank you @User the thread partially helped i tried removing the selection of all tables and it still didn't work but since i only needed 2 of them I decided to take the rest of the tables and turn out it work... I then tried one by one and found out that 3 of my tables were not working with real-time and were breaking the rest... I believe it my have something to do with my policies for those tables since they are a bit complex.
g
I’d recommend you post an issue on GitHub with an example of what does not work RLS wise. Sort of wonder if a very slow RLS resolution might break some timing in realtime processing.