Thanks for the reply <@401792058970603539> , yes i...
# javascript
p
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
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
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
When you say you removed it shortly after, do you mean you have removed that code or that you've unsubscribed from it?
p
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
Yes that could be it