Repository navigation
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
With supabase-js@2.42.5 and the ssr auth helper package, after a user logs in, the below warning is logged to the server console five times, with a fairly minimal SvelteKit app. This happens despite the fact that none of my code is calling session.user, nor am I destructuring the user property from session, or destructuring with ...rest-type syntax.
Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and many not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
https://github.com/j4w8n/getsession-warning
Expected behavior
The warning should not log when dev code doesn't explicitly call session.user.
Root Cause
I figured out why the first three logs happen: the Supabase client's server-side storage, from +layout.ts, is returning stringified JSON. You can see this in the docs. JSON.stringify() causes each property of session to be touched during the stringify process, which inevitably calls session.user. So, each time _useSession() is called, whether implicitly through dev code like getSession() or explicitly with internal auth-js processes, the warning is being logged.
I can't figure out where the final two warning logs are coming from. Could be from the same client initialization as above, but perhaps whatever triggers it is getting run asynchronously, so it's logging later.
Even if this warning wasn't an issue in the context of ssr, it could still be problematic, as the auth-js client itself calls session.user when updating a user, setting a session, refreshing a session, and more - at least some of which could theoretically happen server-side.
System information
- OS: Windows, with or without WSL.
- Browser N/A
- Version of supabase-js: 2.42.5
- Version of ssr: 0.3.0, but it should happen on earlier versions too I'd think.
- Version of Node.js: N/A
Additional context
supabase/auth-js#873
supabase/auth-js#873 (comment)
https://tc39.es/ecma262/multipage/structured-data.html#sec-json.stringify
https://tc39.es/ecma262/multipage/structured-data.html#sec-serializejsonproperty
https://github.com/supabase/auth-js/blob/master/src/GoTrueClient.ts#L1111-L1124
Activity
j4crev commentedon Apr 27, 2024
Someone having this issue when:
updateUser, Code in supabase-js callsgetSession(), which now throws a warning when using in combo with ssr #1010 (comment)getAuthenticatorAssuranceLevel, Can't get rid of getUser() warning auth-js#873 (comment)j4crev commentedon Apr 28, 2024
It's likely the other two warnings, that I couldn't figure out how they are triggering, are triggered when SvelteKit checks if passed values are POJOs, in certain situations. See supabase/auth-js#873 (comment)
kangmingtay commentedon May 2, 2024
hey @j4w8n, we made another attempt in this PR to further cut down on the repeated warning logs returned - basically everytime we detect that a new session is saved, we set a flag to suppress the warning internally
j4crev commentedon May 2, 2024
Thanks @kangmingtay. I suspect that PR will resolve issues for some people - specifically the ones exclusively experiencing this when calling things like
updateUser(). However, this has basically no effect for SvelteKit users - at least not on initial login and hard refreshes - because of the nature of what I explained in the first paragraph of the Root Cause section.As an aside, how do I test an RC? I added an override in my package.json, and after doing
bun installit claimed it installed one thing. When I go to the auth-js package.json the version is 2.64.2-rc.1, but none of the code from the release is in there - I had to add it manually to test. I was looking in dist/main/GoTrueClient.js, but I even glanced at the .ts version in src and saw nothing. I had this experience with pnpm as well, in another demo app.j4crev commentedon May 2, 2024
@kangmingtay looks like there is something wrong with the build process for RCs. If you checkout the code on npm, you'll see the PR code is not there.
https://www.npmjs.com/package/@supabase/auth-js/v/2.64.2-rc.1?activeTab=code
kangmingtay commentedon May 3, 2024
@j4w8n ah good point, not sure why the release workflow got skipped in the first attempt but i reran it and it's published to npm so you should be able to test it out
kangmingtay commentedon May 3, 2024
@j4w8n yeah your analysis is right, any method that implicitly accesses the user property in the session object will trigger the warning log.
i think we can implement your suggestion here so the warning is only logged once per proxy session, but will need some time to test this out since we're currently quite tight on bandwidth
vehm commentedon May 3, 2024
Confirming that we are continuing to receive the warning in SvelteKit after #895 as mentioned here.
Will follow.
j4crev commentedon May 3, 2024
Until this issue is resolved, and perhaps even after that, I've tweaked my demo app - v0.3.0 - to where I no longer receive any warnings.
My solution is done in a legitimate way, which checks all of the security boxes. The code in hooks.server.ts verifies the JWT and uses it's decoded data to craft a validated session. This session will pass any internal auth-js checks, as well as type checks.
https://github.com/j4w8n/sveltekit-supabase-ssr
silentworks commentedon May 7, 2024
I think the suggestion here from @j4w8n is great but I'd also like a way to suppress this warning completely in production build. I don't want this to be logging inside of my application terminal when its being run in production mode.
fix: limit proxy session warning to once per client instance (#900)
itsmikesharescode commentedon May 20, 2024
any update?
Rollback @supabase/auth-helpers-sveltekit to ^0.11 to avoid https://g…
Sveltekit 2 migration! (#76)
104 remaining items
jdgamble555 commentedon Nov 7, 2025
@rossvold - I believe the error actually is fixed, but both examples still use
getSession(), which we no longer need to use.https://supabase.com/docs/guides/getting-started/tutorials/with-sveltekit
https://supabase.com/docs/guides/auth/server-side/sveltekit
Here is my SvelteKit repo copying the example
User Managementapp. I didn't get any issues, but let me know if you do:https://github.com/jdgamble555/sveltekit-supabase-demo
I'm working to help revamp the docs for all Frameworks:
Follow the Docs Thread here:
supabase/supabase#40985 (comment)
J
rossvold commentedon Nov 7, 2025
I understand but this issue is not closed until the documentation is corrected then.
I'm not going to NOT follow the documentation and do something undocumented to get it working.
mandarini commentedon Nov 7, 2025
@rossvold I undestand your very valid frustration. Please bear with us until we update the documentation. I will not close this issue until we update it, ok?
jdgamble555 commentedon Jan 21, 2026
@mandarini - Is this still being worked on? It's crazy to me the docs have been incorrect for this amount of time.
J
mandarini commentedon Jan 22, 2026
@jdgamble555 I think there's another issue for that, including @ChrisChinchilla ? I have asked internally for this, please bear with us.
chanmathew commentedon Feb 13, 2026
@mandarini any update on this? Every day this clutters our SSR logs and it's unbelievably frustrating how a simple thing like this has still not been resolved for over a year. I'm honestly about to migrate our paid account off Supabase because of this, not the mention the recent outage with no comms. So disappointed in Supabase.
jdgamble555 commentedon Feb 13, 2026
@chanmathew - IDK if they are ever going to update the docs as it has been a few months and they are "deep" into updating them still... I think they are not making this a priority.
Either way, the actual issue is fixed if you implement it correctly. Here is my SvelteKit version:
supabase/supabase#40985 (comment)
J
rossvold commentedon Feb 13, 2026
Been running basically this config for 1 months and can confirm that it does work.
I don't understand why they can't just update the 2 pages of documentation for this.
Why spend time fixing this issue, and then completely ignore updating the correlating to the fix 😅😅
ChrisChinchilla commentedon Feb 17, 2026
Hey all, regarding docs. There's a lot more than 2 pages of docs as part of the change, and until this week, the docs team was just me, and I was also on holiday last week. So, some things do take a little longer than I/we hope. But I am back on it this week, and several pages are already updated. Thanks!
vehm commentedon Feb 17, 2026
Hoping this is the same sentiment for everyone in this thread, but the frustration expressed here is by no means directed at one person. I appreciate the work everyone has done on this, I just wish that this issue as a whole received attention sooner.
Thank you for your work on this!
magick93 commentedon Mar 13, 2026
So, is there a way to turn this annoying message off?
jdgamble555 commentedon Mar 13, 2026
@magick93 - problem is not longer turning off the message, but the docs need to be updated so the message won't be seen.
See: supabase/supabase#40985 (comment)
J
mandarini commentedon Jul 22, 2026
I think we can close this issue now. What do you think @jdgamble555 ?
mandarini commentedon Oct 16, 2026
Hi @j4crev, thank you for opening this issue! 💚
Closing. Where this landed:
session.user, not the session, so framework serialization and POJO checks no longer trigger it.getUser()has validated the session.getClaims(). Docs were tracked in Clarify when to usegetClaimsandgetUserand discourage usage ofgetSessionsupabase#40985, now closed.The warning still fires when
session.userproperties are read on the server from an unverified cookie. That is intended.If it still shows on a current version with the current guide, open a new issue with a repro and the version.