You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon an error the method _callRefreshToken does not resolve the refreshingDeferred, leading to dangling promises. If an error during a refresh token request occurs the deferred is kept for ever, and all subsequent calls to _callRefreshToken will await the deferred for an infinite time as it will never resolve.
The condition if (this.refreshingDeferred) will be true and this.refreshingDeferred from the former refresh request in step 7 is returned and never rejected nor resolved.
Expected behavior
The deferred should be resolved with the error result and then be reset to null.
Move return await this.refreshingDeferred.promise out of the try block and don't await it (return this.refreshingDeferred.promise). This is to avoid multiple entries into catch and finally block, when the error is not an AuthError and therefore re thrown (see 3).
Bug report
Describe the bug
Upon an error the method
_callRefreshToken
does not resolve therefreshingDeferred
, leading to dangling promises. If an error during a refresh token request occurs the deferred is kept for ever, and all subsequent calls to_callRefreshToken
will await the deferred for an infinite time as it will never resolve.To Reproduce
if (this.refreshingDeferred)
const { session, error } = await this.api.refreshAccessToken(refresh_token)
The condition
if (this.refreshingDeferred)
will be true andthis.refreshingDeferred
from the former refresh request in step 7 is returned and never rejected nor resolved.Expected behavior
The deferred should be resolved with the error result and then be reset to null.
Code sandbox
I created a sandbox to simulate the behavior.
Auth Error
Generic Error
Same scenario as Auth Error but with Button "Refresh Generic Error", throws the error instead of resolving with an error response.
Success case works as expected
Suggested Fix
this.refreshingDeferred = null
into afinally
block so it gets reset in success and error case.AuthError
, resolvethis.refreshingDeferred
with the error result in the catch block.AuthError
, rejectthis.refreshingDeffered
with the thrown errorreturn await this.refreshingDeferred.promise
out of the try block and don't await it (return this.refreshingDeferred.promise
). This is to avoid multiple entries into catch and finally block, when the error is not anAuthError
and therefore re thrown (see 3).I created a sandbox simulation with the suggested fix
System information
Additional Context
This regression seems to have been introduced in 1.23.0-next with #285.
The text was updated successfully, but these errors were encountered: