Skip to content
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

Re-instantiation of the supabase auth client and memory leak? #153

Closed
trueter opened this issue Feb 16, 2023 · 3 comments · Fixed by #222
Closed

Re-instantiation of the supabase auth client and memory leak? #153

trueter opened this issue Feb 16, 2023 · 3 comments · Fixed by #222
Assignees
Labels
question Further information is requested

Comments

@trueter
Copy link

trueter commented Feb 16, 2023

Hello!
I am investigating an issue that is presenting itself in the following manner:
image

By starting my nuxt app in debugging mode and comparing two memory snapshots I was able to identify an excess amount of timers created:

image

Using the debugger I was able to trace this back to the startAutoRefresh function of the supabase gotrue client, which is called everytime the auth client is created.

Here's what I believe happens:

  • Each time I call serverSupabaseUser() (per h3 event) a new SupabaseAuthClient is created
  • Each time a SupabaseAuthClient is created, a new setInterval timer is started, and they are not cleaned up

My questions are:
Is the creation of a new supabase auth client per request expected?
I see that the supabaseClient is attached to the event here. Is there a way we can destroy or clean it up at the end of the request?
Do you have any insight into why it is necessary for the server side code to keep timers running for refresh tokens? Could disabling this be an option?

Thanks!

===
node 19.1.0
nuxt 3.2.0
nuxt/supabase 0.3.1
gotrue-js 2.4.2
supabase/supabase-js 2.7.1

@trueter trueter added the question Further information is requested label Feb 16, 2023
@larbish larbish self-assigned this Feb 20, 2023
@sdaoud
Copy link

sdaoud commented Apr 6, 2023

I'm very interested in this too. We seem to be getting similar memory leaks.

@Thexumaker
Copy link

Any update on this?

@trueter
Copy link
Author

trueter commented Jun 6, 2023

Seems to have been adressed by #189
Memory consumption looks more consistent now (last reboot = patch applied):
image

Would love to hear what others have been observing before closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants