Skip to content

fix(react-native): await token refresh on Android instead of resolving stale (FR-25937) - #93

Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/rn-android-refreshtoken-wait
Closed

fix(react-native): await token refresh on Android instead of resolving stale (FR-25937)#93
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/rn-android-refreshtoken-wait

Conversation

@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator

FR-25937 — Android refreshToken() resolves before the refresh completes

FronteggRNModule.refreshToken() called auth.refreshTokenIfNeeded(), which starts the refresh in the background and returns immediately, then resolved "". Callers doing await refreshToken(); read state.accessToken therefore got a stale token. There was also a cross-platform shape mismatch — iOS awaits and resolves a Bool, Android resolved a string.

Fix

Use the SDK's suspend refreshTokenAndWait() on Dispatchers.IO and resolve its Boolean result (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 final fronteggAuth singleton, which can't be mocked in this toolchain).

…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.
@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator Author

Superseded by #100, which combines FR-25937/38/39/40 into a single PR. Branch kept.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant