fix(react-native): await token refresh on Android instead of resolving stale (FR-25937) - #93
Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
Closed
fix(react-native): await token refresh on Android instead of resolving stale (FR-25937)#93dianaKhortiuk-frontegg wants to merge 1 commit into
dianaKhortiuk-frontegg wants to merge 1 commit into
Conversation
…g stale (FR-25937) Android refreshToken() called refreshTokenIfNeeded() — which starts the refresh in the background and returns immediately — then resolved "", so callers awaiting refreshToken() read a stale accessToken. Use the SDK's suspend refreshTokenAndWait() on Dispatchers.IO and resolve its Boolean result, matching iOS which already awaits a Bool.
Collaborator
Author
|
Superseded by #100, which combines FR-25937/38/39/40 into a single PR. Branch kept. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FR-25937 — Android
refreshToken()resolves before the refresh completesFronteggRNModule.refreshToken()calledauth.refreshTokenIfNeeded(), which starts the refresh in the background and returns immediately, then resolved"". Callers doingawait refreshToken(); read state.accessTokentherefore got a stale token. There was also a cross-platform shape mismatch — iOS awaits and resolves aBool, Android resolved a string.Fix
Use the SDK's
suspend refreshTokenAndWait()onDispatchers.IOand resolve itsBooleanresult (rejecting on exception). This blocks until the refresh actually finishes and aligns the resolved shape with iOS.Verification
Compiles via the example-app Gradle harness (
:frontegg_react-native:compileDebugUnitTest). The method itself isn't unit-testable in isolation (depends on the finalfronteggAuthsingleton, which can't be mocked in this toolchain).