-
Notifications
You must be signed in to change notification settings - Fork 280
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(clerk-js): Revalidate environment on window focus for Keyless #4813
fix(clerk-js): Revalidate environment on window focus for Keyless #4813
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: 27e9630 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const maxRetries = 2; | ||
|
||
for (let i = 0; i < maxRetries; i++) { | ||
const { | ||
authConfig: { claimedAt }, | ||
} = await environment.fetch(); | ||
|
||
if (claimedAt !== null) { | ||
forceUpdate(); | ||
break; | ||
} | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you claim in dashboard and quickly switch the fetched environment will not reflect the claimed status. We are trying to fetch a couple of times until we get it.
* Revalidates environment on focus, highly optimized for Keyless mode. | ||
* Attention: this is not a generic solution, and should not be used for revalidating environment inside UI components that are end-user facing (e.g. SignIn) | ||
*/ | ||
function useRevalidateEnvironment() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently there is not pattern for "updating" the environment context after a component has already mounted. This is a quick hack to get this working for Keyless mode, which is a dev facing UI component.
…o-open-in-new-tab
Description
We have decided to open a new tab for developers to claim their application while on Keyless mode. This means we need to "listen" for the updated
claimedAt
property from environment when the developer has claimed and returns back to the tab where application is running.Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change