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

fix: refresh token sync across multiple tabs #461

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

kangmingtay
Copy link
Member

@kangmingtay kangmingtay commented Sep 30, 2022

What kind of change does this PR introduce?

error instanceof AuthRetryableFetchError &&
this.networkRetries < NETWORK_FAILURE.MAX_RETRIES
)
this._startAutoRefreshToken(NETWORK_FAILURE.RETRY_INTERVAL ** this.networkRetries * 100) // exponential backoff
Copy link
Member Author

@kangmingtay kangmingtay Sep 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems error prone too - in the event of network failure, the retry interval could possibly fall outside of the reuse interval error but currently the client has no way of knowing what the reuse interval is

i think it's safe to assume that if the network failure lasts longer than the reuse interrval, then the user should be forced to login again

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree with you that the user should be logged out here. We can always take another look at this if it becomes a bigger issue in the future.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kangmingtay, @alaister. A robust approach could be to listen for a network status change.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine

This could affect users who are traveling and have their laptops offline for a day. Ideally, you'd want to stay logged in, it's an edge case, but a listener would capture these events. Then you can avoid long polling.

Copy link
Member

@alaister alaister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

error instanceof AuthRetryableFetchError &&
this.networkRetries < NETWORK_FAILURE.MAX_RETRIES
)
this._startAutoRefreshToken(NETWORK_FAILURE.RETRY_INTERVAL ** this.networkRetries * 100) // exponential backoff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree with you that the user should be logged out here. We can always take another look at this if it becomes a bigger issue in the future.

@kangmingtay kangmingtay merged commit 477d586 into rc Oct 4, 2022
@kangmingtay kangmingtay deleted the km/fix-refresh-token-sync branch October 4, 2022 01:23
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

🎉 This PR is included in version 2.0.0-rc.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants