supabase / auth-js

An isomorphic Javascript library for Supabase Auth.
MIT License
321 stars 153 forks source link

feat: acquire lock around visibility change callback #764

Closed hf closed 10 months ago

hf commented 10 months ago

Similarly to how the refresh token ticker needs to acquire the lock before checking whether the session needs to be refreshed, we need to do the same for the visibility change callback. This is difficult to spot because when one uses tabs instead of windows, there's often just one tab visible at once. But when using multiple windows, a window is not hidden when not focused, so events like waking from sleep will cause all windows to refresh the token at once. Adding the lock will serialize access, meaning that all windows will check the session, but only one will refresh.

github-actions[bot] commented 10 months ago

:tada: This PR is included in version 2.48.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: