Replies: 1 comment
-
Related - #6051 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm getting unexpected behavior - probably because I don't know how this works.
Here's my route structure:
/login
, there's a login button for github oauth.+layout.svelte
knows someone's now logged in.That's when this code runs:
The
hook.js
handle()
is reading the cookie and passing data toevent.locals
.In
+layout.server.js
, I'm returning asession
object fromevent.locals
, to read asdata.session
in+layout.svelte
.I'm logging various points in the flow, and now get this output of what's happening when the code above is run. I suspect the first three lines are because of what supabase is doing to execute the login and callback.
What I'm not understanding is why
app/+page.server.js
is logging before+layout.server.js
- implying it's running before+layout.server.js
.What's interesting is that when I click the logout button, I run
await invalidate()
and thengoto('/')
, but the logs on this always show+layout.server.js
first.Also, when the login process and code finishes, two parts of the app should now reflect that a user is logged in:
/app/+page.svelte
will now show user data/+layout.svelte
will now show a logout button in the navbar.However, with the code above, only the /app page will render user data.
If I change
await invalidate('/')
toawait invalidate()
, then both will happen.What am I not understanding? Thanks!
Update
Actually, if I read the docs really slow - like two times, I might know what's going on with
invalidate()
.I'm now thinking that
'/'
would only re-runload
in/+page.server.js
, and doesn't touchload
in+layout.server.js
. But once I remove the'/'
frominvalidate('/')
the remaininginvalidate()
also runs theload
function in+layout.server.js
, hence updating data in+layout.svelte
and properly showing the logout button becausedata.session
is populated.Beta Was this translation helpful? Give feedback.
All reactions