-
Notifications
You must be signed in to change notification settings - Fork 962
fix(app-check): Prevent redundant exchangeToken calls in debug mode #9187
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(app-check): Prevent redundant exchangeToken calls in debug mode #9187
Conversation
|
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.
Great PR, thanks! There's one nit (typo) and you need to run yarn format
and I think it should be good.
const appCheck = initializeAppCheck(app, { | ||
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY) | ||
}); | ||
const appCheckServie = appCheck as AppCheckService; |
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.
nit: typo -appCheckServie
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.
Thanks @hsubox76 , I've updated the branch.
Thanks again, this should go out in the next release, which is planned for Aug 7. |
Thanks @hsubox76 🚀 |
This PR addresses a race condition in
getToken()
where multiple concurrent calls could each pass the!state.exchangeTokenPromise
check before any of them had set the promise, resulting in redundantexchangeToken()
network requests.Changes
await getDebugToken()
call before theif (!state.exchangeTokenPromise)
check to ensure token preparation occurs before promise coordination logic.state.exchangeTokenPromise
immediately, ensuring concurrent calls share the same in-flight promise.Notes
Resolved #9184