supabase / auth-js

An isomorphic Javascript library for Supabase Auth.
MIT License
319 stars 152 forks source link

fix: add memory leak warning to `GoTrueClient` for unsupported runtimes #867

Closed ghost closed 2 months ago

ghost commented 3 months ago

Adds a warning regarding memory leaks in some javascript runtimes that do not support setInterval dereferencing (allowing users to better/manually clean-up supabase instances, freeing memory and allowing for garbage collection)

What kind of change does this PR introduce?

Warning/bug fix

What is the current behavior?

Currently, in environments that are neither Node.js nor Deno, a memory leak occurs due to setInterval not being dereferenced. See https://github.com/supabase/gotrue-js/issues/856. The implementor is never warned that such a memory leak exists for their specific runtime (such as in React Native).

This implements a warning, at least, that fires only once, to notify implementors to better clean-up instances in their environments (such as manually calling stopAutoRefresh when ready to dispose of instances).

What is the new behavior?

Noted above.

Additional context

https://github.com/supabase/gotrue-js/issues/856