Previously __loadSession didn't wait for initialization to finish if stack guards were not supported which broke some flows.
This fix attempts to identify recursive calls to _initialize, i.e. recursive waiting for inititalizePromise:
When the session is detected from URL, GoTrueClient needs to call getUser(accessTokenFromURL) to fetch the user. But this then depended on _useSession, which calls __loadSession which waits for initializePromise. With this PR, it no longer calls _useSession if the access token is provided.
_onVisibilityChanged could be called from within #_initialize which would block. Now it's called with a setTimeout of 0 so the processing takes place in the next event loop pass.
_startAutoRefresh which calls _onAutoRefreshTokenTick also could be called from within #_initialize and the same setTimeout with 0 trick is applied.
This should get rid of all issues with a loading spinner / endless waits when fetching the session from the URL or with password recovery.
Previously
__loadSession
didn't wait for initialization to finish if stack guards were not supported which broke some flows.This fix attempts to identify recursive calls to
_initialize
, i.e. recursive waiting forinititalizePromise
:GoTrueClient
needs to callgetUser(accessTokenFromURL)
to fetch the user. But this then depended on_useSession
, which calls__loadSession
which waits forinitializePromise
. With this PR, it no longer calls_useSession
if the access token is provided._onVisibilityChanged
could be called from within#_initialize
which would block. Now it's called with asetTimeout
of 0 so the processing takes place in the next event loop pass._startAutoRefresh
which calls_onAutoRefreshTokenTick
also could be called from within#_initialize
and the samesetTimeout
with 0 trick is applied.This should get rid of all issues with a loading spinner / endless waits when fetching the session from the URL or with password recovery.