fix: populate user claims alongside session in SPA mode#594
fix: populate user claims alongside session in SPA mode#594zlotnika wants to merge 2 commits intonuxt-modules:mainfrom
Conversation
|
@zlotnika is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
commit: |
|
Hey @zlotnika, thanks for the PR. I don't get it, |
|
@larbish To clarify the race: That said, I should be transparent: after upgrading our app to 2.0.6 and removing our workarounds (we had a client plugin manually hydrating the session ref), we're not currently able to reproduce this. Our tests pass with The fix still seems correct to me — |
|
Actually, digging into the 2.0.6 source more carefully — I think the current design is intentional and correct:
The Our issue was a client plugin we had that was interfering. Removing it and upgrading to 2.0.6 resolved everything. Closing this — sorry for the noise. |
|
Reopening — I was wrong about Our workaround is a client plugin that manually hydrates The fix in this PR — calling |
|
👍 to this fix — wanted to share an additional symptom we hit on v2.0.6 in SPA mode ( Beyond So the current
Moving the call into Hoping for a merge soon! 😄 |
#571 added getSession() in SPA mode to restore the session before auth middleware runs. But this pre-sets currentSession before onAuthStateChange is registered, so when the SIGNED_IN event fires the handler skips it (session already matches) and getClaims() never runs — leaving useSupabaseUser() null on page load.
Fix: call getClaims() right after getSession() returns a session, same place currentSession is set.