https://supabase.com/ logo
I’m not using RLS
# javascript
j
I’m not using RLS
g
The reported bug and fix was only with RLS on. I don't know what a useRealtime hook is. Can you give more info on what you are doing and what is not working?
j
Yeah sure
but I tried the actual supabase client
with .channel
and it still did not work
but onClose seemed to work
g
I'd say that code is suspect based on age for realtime. Many changes were made in the late 2021 time frame. I'm not looking thru the code though, just the july 2021 last release.
What client are you using? If you have javascript the supabase-js is best way to do realtime. There is more work if you use realtime-js directly.
j
I used supabase-js
It worked for requesting the data
but did not work for updating it via subscription
I also tried to use realtime-js and it didn't work
g
So supabase-js does not have the user use channel() is why I mentioned that. realtime-js requires extra token to be passed in, and for awhile docs were not complete on that change, but may be now. What was your supabase-js call? Did you set up replication on the SB database side?
j
Yea I turned it on replication for the table
for supabase I used .from("table_name")
and then did
.on("*", the callback)
and then subscribed
g
There have been a couple of people who had to get support to fix their hosted realtime (not sure what the issue was). But they had it working and then it just quit. Don't know if related to the bug you linked. In your case I don't have enough info to guide you. If you have the current supabase-js client, are using hosted SB, have replication actually checked for the table it should certainly work without RLS.
Not sure in your environment if you can see the network flow in dev mode on the browser. You should see a websocket with heartbeat pings if you are connected.
You can also add .subscribe((status) => { console.log('status', status)}) to monitor connection status
j
I’ll try this tomorrow
The web socket does ping
And it was working at one point
for like 30 seconds
@garyaustin I’m now using supabase.js specifically and I get the status code 101 on the web socket and I copied exanple code from next js example in the supabase.js GitHub and I get the schema changed CLOSE and SUBSCRIBED but nothing else
So subscribe works
It closes immediately after tho idk why
g
If your RLS is off, you have latest -js code, are subscribing to correct table, and double checked replication, I would contact support There have been enough strange issues on individual realtime environments it could be your instance.
j
Okay so some updates: I tested it in a regular JS file and it works
So for some reason
The react useEffect closes the subscription immediately
I’m not sure why 🤔
g
Is it executing more than once? Or are there two of them for different pages. Someone had an issue I worked with that when the page changed the new realtime connection started before the old one finished closing as part of the useEffect cleanup. A delay somewhere solved the problem. An issue was also generated in either realtime or realtime-js GitHub.
j
Yea it’s executing more than once
Like 3 times open close
g
If you can look at websocket you might see a close go out about same time as an open and realtime gets confused.
j
Yea it’s the same time
Where should I put the delay
I’m sending an image of console output
g
I don’t remember but here is the issue. The user eventuality gave up and moved his code around. I would add your experience to that issue. https://github.com/supabase/realtime/issues/254
I don’t know react well enough to help.
j
I’m not sure if is the same issue since my subscription doesn’t work at all
And I’m not routing to anything
g
Well then something is causing your useEffect to run more than once.
j
It’s running like 4 times on start 😳
g
What are you using in the [] and why is it changing so much?
j
I got it to run 2 times now
Still not enough
g
Try putting that suggested await close all connections recommend by the SB employee in that issue.
j
What fixed it was turning strict mode on
It’s a setting
And for some reason it’s enabled by default 😭
t
Hi @Joshios ...the strict mode is on your dashboard right?
j
It’s in next js setting config
t
Hi @Joshios I removed the strict mode in next config but still not getting real time updates
t
@Taofiq helooo did u manage to fix it? I couldn't receive real time subscription updates as well
s
reactStrictMode: false,
worked for me--thank you for the lead. Ideally it would be enabled so I'm going to dig further...
t
Hey @Tekey No i did not
t
where do I put this? I am not using nextJS. Sorry am a noobie still
t
@scrapdog you mean when you create like say a post on /create endpoint u see what u created on the home page without refreshing the page?
t
Im facing this rn
s
this change is specific to Next.js, what are you using?
correct, in my case I'm following the Supabase Happy Hour #2-3 youtube videos
t
Just using react
g
@Tekey you should probably start a new thread in general. You are bouncing between several threads, which is fine for quick questions, but now starting to present data which would be more useful in its own thread.
t
Send link pls @scrapdog
s

https://www.youtube.com/watch?v=P9X_qVt10DY

j
What even is strict mode
I don’t mind it being disabled
"Suggested: We strongly suggest you enable Strict Mode in your Next.js application to better prepare your application for the future of React."
j
I mean in production my product works
Strict mode is dev only