I'm having trouble with `session.data` being undefined
Starting from the with-auth example,
user_id
is sometimes undefined when e.g. refreshing the page.
I've made a minimal reproduction of the issue here:
https://github.com/metruzanca/solidstart-getSession-bug-repro
First commit is the initted project, second is the code that's causing the issue.
I've also got a video showing off the problem.19 Replies
Video reproduction / explanation of the setup (also included in the repo)
if it's only during hmr, could you check https://discord.com/channels/722131463138705510/1189503397091606548/1189537899394371655 ?
This issue also works in production
there has been other accounts of weird stuff happening with context: https://discord.com/channels/722131463138705510/1189503397091606548 maybe good to add an issue in the solid start gh repo, or add a comment here https://github.com/solidjs/solid-start/issues/1185
GitHub
[Bug?]: Issue with context who don't return the value · Issue #1185...
Duplicates I have searched the existing issues Latest version I have tested the latest version Current behavior 😯 Hello I have a very strange bug with the new solid-start template : I have a librar...
Already made an issue yesterday actually https://github.com/solidjs/solid-start/issues/1192
GitHub
[Bug?]:
useSession().data
value inconsistent · Issue #1192 · soli...Duplicates I have searched the existing issues Latest version I have tested the latest version Current behavior 😯 Sometimes session.data.userId is undefined when expected to be defined. Expected be...
I'll take a look, maybe comment + reference
nice
really wanna get this working so I can keep using solidstart 😅
ye, was to be expected some new bugs would arise from the new beta. thanks for leading the way and finding them!
I just wasn't expecting the first but I run into to be this.. road blocking. beta1 was buggy but it was all negligible stuff
Actually beta1 was quite stable
it got quite stable
but it wasn't from the start
I did have to do the good old make new projecte and copy over files into existing project to update version, thing once but aside from that, beta1 treated me well.
Though, can't say I've used a lot of the server$ features. I'm using them a lot more now
Anyways, thanks for taking the time.
r u trying to access the context inside the server-function?
ye ur welcome 👍 sadly can't help too much. can only repeat what i have seen passing by recently
because it was only when refreshing the page right?
i wonder if it's something like: during client navigation it happens inside the client and context is available, but when refreshing the page it goes to the server and there it isn't?
In theory, the function is in a "use server" file, so it should only ever run on the server afaik
yeah, I need the session.data.userId, but I can't determine why its undefined sometimes when visiting the page
Even in production its got this behaviour
mm, i remember alexis saying something about accessing context in a server-function
@lxsmnsyc 🤖 does this ring a bell?
it's a getRequestEvent so it should work
@bigmistqke Absolutely wanted to keep using solidjs (after briefly moving to astrojs and already missing the form actions DX) managed to find a workaround.
https://github.com/metruzanca/solidstart-getSession-bug-repro/commit/17630999eb7db501defebe3fd801aa7db83f6c30
It does need some error checking though!
nice work, that will be helpful in finding the root cause.
Like, if session doesn't exist, process.exit()'s
Gonna find a good way to check that then add that to the workaround
Easy enough, just add some good old try catch and don't assert not falsey for cookie xD
https://github.com/metruzanca/solidstart-getSession-bug-repro/commit/ed2020900b44202ad3bbe8f6b310946c3e6cb52a
But yeah, this works now and is probably good enough to keep going until Jan 1st when the solid team gets back from holidays.