i'm trying to use realtime but it doesn't seem to ...
# javascript
a
i'm trying to use realtime but it doesn't seem to notice when updates are made,
Copy code
ts
  supabaseServer.from<Workspace>('workspaces').on('UPDATE', (payload) => {
    console.log(payload)
  }).subscribe();
am I doing something wrong? thanks!
g
Is only update not working? Do you have RLS on that table? Do you have replication on for update and that table selected?
a
RLS is off and I don't think replication is on but I'll check
oh wait RLS is on, but
supabaseServer
is using the token that bypasses it (forgot what its called)
g
Replication has to be on for update and that table. Make sure you have latest drivers.
p
the same issue that I have.
g
@User @User I just used my test instance with a service key and with RLS on, select policy false... I can confirm service key does not bypass RLS for realtime. Now the question is it supposed to work...
a
hm odd
i feel like they said something about RLS and real-time
g
RLS works fine with realtime for normal users. It is just service role is not bypassing RLS. I'm reporting the issue for clarification.
a
huh well shit lol glad i brought this up then
g
In thinking about it though, not sure this is a valid use case. You are not supposed to use service role on a browser. Does the realtime interface with websockets work on a server? I don't do any server stuff so not sure.
@User @User Worked with Supabase on this and two things. All instances were just finished updating about 12 hours ago AND if you are testing with service_role_key on a browser you need to clear local storage if you ever logged in a user normally... Remember not to really use service_role on a browser clent.
a
Right, this isn't on the browser, its on a nodejs script @User
Would that be the issue then?
g
Well, they are assuming it was your instance not being upgraded yet if you were actually running on a server. You can read the issue for the debug "session".
a
Yeah likely my instance not being upgraded, not sure how I can do that, if it's manual or not
g
If it is still not working, then might be a similar type issue on the server, the browser issue was a authed client logged in and out earlier being sent up instead of just the service role because a jwt was hanging around.
If you are on the Supabase infrastructure they are all supposed to be updated as of yesterday sometime.
a
I'll restart my project server and try again here, I'll let you know if there are any updates
Yup, still doesn't seem to work
Here's what I have for supabase initialization
Copy code
js
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
  fetch: fetch
})

export const supabaseServer = supabaseSecretKey ? createClient(supabaseUrl, supabaseSecretKey || '', {
  fetch: fetch
}) : null
g
I suggest you jump in and shout the Supabase guy in that thread and mention you are on server and show that and you still have issue. I can confirm service role key now works as expected with no left over jwt on the browser.
a
Alright, thanks!
g
Can you test without the preceding anonkey call. I have no idea how the server stores tokens and such, but the same type issue with the anon key being used may be interfering with the service role on the server also...
a
Hm that's a good point, i'll try it
No difference
Wait let me try something
Yeah nope not working
g
So this is what my realtime.subscription table looks like with just a service role: With the anonkey user hanging around it had an "authenticated" user in that table...
a
Yeah there's nothing in my realtime.subscription table
g
Ouch, that's not good...
a
Quite fun
I logged what the
.subscribe()
returns and it does make the websocket connection with the right service key
g
At this point probably best to let Supabase figure it out with you as I'm just guessing, but if there is no entry in that table then there will be no updates.
a
Yeah I'll wait for a response
g
I just reviewed the thread and you never replied if you had replication (from database tab) turned on for that table. Subscribe still connects like there is no issue even if table is not monitored....
a
How would I check if I had it on for the table?
g
you select what you want monitored and then click at the far right to pick which tables...
a
son of a bitch i didn't have it enabled
g
I should have pushed harder on that, but then got caught up in you using service role and it not working on my test system.... SIGH