-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getSession()
does not get called on page load. should warn user
#3722
Comments
If I remove |
I had the same issue and had to remove the |
same here, |
@benmccann I'm not sure this is a bug, I just tried to debug it, and what I found out was that that page was prerendered ( import node from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
kit: {
adapter: node({
out: '_build',
precompress: true
}),
prerender: {
enabled: false
}
}
};
export default config; |
@benmccann but there should be at least a warning that session is being used on prerendered page, something like that. |
@PH4NTOMiki Thanks for looking into this ! Gonna give it a try with the full scale non-repro project and keep you posted 👍 |
We have the same for the query string already. I haven't booked closely at this issue, but perhaps it could make sense to do the same with session |
@PH4NTOMiki That did indeed do the trick, thanks a lot ! And yes, a warning would be helpful, especially since it was a somewhat undocumented change post |
@zommerberg @eriknyk what about you, does that solve the issue? |
@PH4NTOMiki Yes, it solves it. |
getSession()
does not get called on page load. should warn user
Happy to tackle this one. Just give the a-ok. |
#3722 (#4811) * feat: Failing test * feat: Prerendering fails for pages that access session * feat: Changeset * fix: Unnecessary cast * feat: Fail on server navigations in dev * feat: Test to make sure runtime prerendering results in error * use options.prerender.default Co-authored-by: Rich Harris <hello@rich-harris.dev>
Not sure if you'd like me to add another issue for this, but I just ran into a related issue where I was accessing the session through |
Weird. I'm 95% sure that I added some error log for this before this issue got closed. |
Yeah, #4811 should've fixed this. |
Oh, pff, I'm stupid -- this is the session store. Yeah, I would open a new issue and reference this one. Be sure to include a small repro with StackBlitz or a GitHub repo. |
Hi, I don't know if this is related, but i get an error: "Attempted to access session from a prerendered page. Session would never be populated." By having enabled: false. This indeed dissapears. But i want to enable prerendering. This code triggers the error: It strange, because i don't really read the session variable. If i delete the parameter, i can run my dev server, but when building with static adapter, it throws the error again.
|
Intended behavior. Also, you're using an old version of Kit. |
Describe the bug
Unfortunately, I haven't been able to get our sveltekit app to work in production past kt@next.206 and adapter-node@next.56.
Since the ssr was always somewhat flunky with our - aside from the login page- completely private app we previously disabled it via the config and on all update attempts in the handle hook.
Now, the issue is always the same, everything runs fine locally, until it gets deployed, where you can't get past the login screen anymore, since the session never gets populated. I recently found out that the issue seems to lie somewhere within adapter-node, since running
dev
andpreview
works flawlessly, but running the build output directly vianode _build
presents the same issue our staging environment showed locally.Any help/pointers would be appreciated, ready to replace our auth code if necessary/it's just us working against sveltekit.
If you have any further questions, feel free to ask !
Reproduction
https://github.com/luhagel/sveltekit-node-session-repro
Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: