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

SIGNED_IN event fired when _onVisibilityChanged is triggered #634

Closed
2 tasks done
kjmph opened this issue Mar 30, 2023 · 2 comments
Closed
2 tasks done

SIGNED_IN event fired when _onVisibilityChanged is triggered #634

kjmph opened this issue Mar 30, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@kjmph
Copy link

kjmph commented Mar 30, 2023

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

When Visibility Change window events are triggered, the SIGNED_IN AuthEvent is triggered. This causes a rewrite of Session in supabase-js's SessionContextProvider, which is suggested to be the top level Context in _app.js for Next.js applications. Thus, it causes a re-render of the web application every time the visibility changed. This happens only when the session token is still valid and hasn't expired. It appears to have been introduced while fixing a React Native error in #76.

To Reproduce

Open a tab with Supabase loaded in an application. Move away from the tab, switch back to the tab. The application will re-render. For further proof, check this code out:

https://github.com/supabase/auth-helpers/blob/2a85f3db6815b8baf7ff44d48c4fc54e2bfba210/packages/react/src/components/SessionContext.tsx#L83-L94

Actual event triggered:

https://github.com/supabase/gotrue-js/blob/2fc278106c1b2b4f4d45d75c9ad3f02588af1cbe/src/GoTrueClient.ts#L1130-L1133

From this callback:

https://github.com/supabase/gotrue-js/blob/2fc278106c1b2b4f4d45d75c9ad3f02588af1cbe/src/GoTrueClient.ts#L1373-L1375

One could also use supabase.auth.onAuthStateChange and print all events to see them triggered.

Expected behavior

If the session's access token is unchanged, don't trigger a SIGNED_IN AuthEvent.

System information

  • OS: macOS
  • Browser: Safari and Chrome
  • Version of supabase-js: 2.12.1
  • Version of Node.js: 19.8.1
@kjmph kjmph added the bug Something isn't working label Mar 30, 2023
@altryne
Copy link

altryne commented Apr 3, 2023

Seems similar to this one
#579

@kjmph
Copy link
Author

kjmph commented Apr 4, 2023

Yes! Thanks @altryne, my apologies, I really did try and search first. I'll move over to that discussion.

@kjmph kjmph closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants