https://supabase.com/ logo
#javascript
Title
# javascript
p

Peter Hase

01/31/2022, 9:15 AM
Thanks for the reply @AmusedGrape , yes it is very strange. I have a previous version of my code that has the same provider code and it works flawlessly, yet in my main code the ˋSIGNED_INˋ event isn’t triggered. Could it be that the event listener for some reason is set up after the token is set in local storage?
s

silentworks

01/31/2022, 9:54 AM
This could be due to multiple onAuthStateChange in your code too, so maybe do a search to make sure there is only one in your project.
p

Peter Hase

01/31/2022, 10:12 AM
thanks for the reply @User ! I have only have one
onAuthStateChange
as seen in
supabaseAuth.tsx
in the gist https://gist.github.com/PedroHase/4be266793731879210fec284ac02f4b9 However, I did tinker around and had a second
onAuthStateChange
for a split second similar to https://dev.to/sruhleder/protected-routes-with-supabase-and-nextjs-381k, but I have removed it shortly after. Could it be that the listener is still active, or that there may be some conflict?
For context, I also use two supabase clients, although one is only for the backend using the service token
s

silentworks

01/31/2022, 11:17 AM
When you say you removed it shortly after, do you mean you have removed that code or that you've unsubscribed from it?
p

Peter Hase

01/31/2022, 12:51 PM
Removed the code. This morning it suddenly worked again, but after my login expired and I tried to login again, it did not trigger
onAuthStateChange
. Interestingly when I try it with another browser (e.g. Firefox) it works again. Could it be that the subscriber is not unsubscribing correctly in https://gist.github.com/PedroHase/4be266793731879210fec284ac02f4b9#file-supabaseauth-tsx-L50-L53 ?
s

silentworks

01/31/2022, 1:45 PM
Yes that could be it