Closed sannajammeh closed 11 months ago
Can you clarify what you mean by "very redundant"? Are you saying that you have a bunch of projects you're creating, and you always have to set this option? Or something else?
This warning is meant to indicate that your current setup could cause negative side effects in your app and ought to be changed. Do you have a use case where this isn't true? Many devs have spent hours troubleshooting issues, only to find out they simply needed to set persistSession
to false
- so this is trying to alleviate that.
Does this warning usually happen with the server clients in your apps?
I'd imagine it would be difficult to run this check once for the whole codebase because there can be a few different clients - client, middleware, server. And we won't know the whole situation until each client is initialized.
Can you clarify what you mean by "very redundant"? Are you saying that you have a bunch of projects you're creating, and you always have to set this option? Or something else?
This warning is meant to indicate that your current setup could cause negative side effects in your app and ought to be changed. Do you have a use case where this isn't true? Many devs have spent hours troubleshooting issues, only to find out they simply needed to set
persistSession
tofalse
- so this is trying to alleviate that.Does this warning usually happen with the server clients in your apps?
I'd imagine it would be difficult to run this check once for the whole codebase because there can be a few different clients - client, middleware, server. And we won't know the whole situation until each client is initialized.
To clarify, your docs state to instantiate the RSC client inside of an RSC. Meaning if I have 5 components fetching data, all those 5 needs that extra option of persistSession
or the warnings won't go away.
You are correct, doing this project wise will result in side effects. My suggestion is to warn it once per singleton. So middelware shows once, then RSC instantiates as a singleton and shows again, subsequent instantiates will not show it.
The local solution for me is another factory function around your factory functions that sets it as default, this would solve it but makes the code a bit less extensible.
I suggest an update to the docs here: https://supabase.com/docs/guides/getting-started/tutorials/with-nextjs So each code snippet actually includes persistSession.
This could be seen as a bug or a docs issue depending on what you guys think is best.
Or even better (though I guess this requires a bit of discussion), default to false on server. If that isn't already the case though.
I can't think of any edge cases where you'd actually want to persist to a fake local storage in NodeJS or Edge runtimes. If you do, that's an edge case and can be opted into by flipping the flag again.
Thanks for your feedback.
So what's interesting here is that the auth helpers use a common createSupabaseClient()
which does have storage
set, and persistSession
is true
. So I'm not sure why you're seeing these warnings. Unless, in addition to using the auth helper clients, you're creating your own one-off native clients for certain things.
Can you share a minimum repo that has the issue?
i got same problem on nuxt3 project when update new version. and today i also use supabase edge functions with simple example.
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm'
export const supabase = createClient(
Deno.env.get('SUPABASE_URL') ?? '',
Deno.env.get('SUPABASE_SERVICE_ROLE_KEY') ?? ''
)
And the problem still same.
@tidusvn05 thanks for the feedback.
For the native client in the edge function, you can pass the persistSession
auth option of false
.
Managed to resolve the issue. Closing.
@sannajammeh what resolution did you use?
When using
@supabase/auth-helpers-nextjs
it is very redundant to always have to disablepersistSession
every time I create a new supabase client. Following your docs will produce this stream of warnings as new clients are created.Please limit this warning to only happen once (as the helpers create a singleton this should not be very difficult). In development it should really only fire a single time when the project boots (first supabase client is created), subsequent creations shouldn't fire this warning at all.
This right here is not pleasant to work with: