fix: make logout() awaitable on both platforms — resolve when the session actually ends - #98
Closed
airowe wants to merge 1 commit into
Closed
fix: make logout() awaitable on both platforms — resolve when the session actually ends#98airowe wants to merge 1 commit into
airowe wants to merge 1 commit into
Conversation
…sion actually ends The bridge logout was fire-and-forget on both platforms: iOS called auth.logout() without the completion overload; Android ignored the SDK's callback parameter. JS had no way to know when the session was actually gone and relied solely on the auth-state event — which can be lost when logout coincides with app-level teardown, leaving the JS state authenticated forever and breaking the next login's state-transition detection (observed on-device). Both native SDKs already expose completion callbacks (iOS FronteggAuth.logout(_ completion:), Android logout(callback:)); the bridge just didn't use them. logout() now returns a Promise that resolves when the native SDK reports completion, and iOS pushes the final auth state to JS before resolving. The JS export is typed Promise<void>. Existing callers that ignore the return value are unaffected.
airowe
marked this pull request as ready for review
July 22, 2026 13:11
Collaborator
|
Superseded by #101 — closing to avoid a redundant/conflicting merge. #101 is built on this commit, so it carries this exact awaitable- Thanks @airowe 🙏 |
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.
Problem
logout()is fire-and-forget on both platforms: the iOS bridge callsauth.logout()without the completion overload, and the Android bridge ignores the SDK'scallbackparameter. JS has no way to know when the session has actually ended and must rely solely on the auth-state event — which can be lost when logout coincides with app-level teardown (see #97 for the event-delivery half of this). The observed failure mode on-device: JS state stays authenticated forever after a logout, and the next login's state-transition detection never fires.Both native SDKs already expose exactly the hook needed — iOS
FronteggAuth.logout(_ completion:), Androidlogout(callback: () -> Unit)— the bridge just doesn't use them.login()is already awaitable;logout()should be too.ios-logout-relogin-green.mp4
Fix
RCTEventEmitter's threading ofhasListeners/pendingObservingState) before resolving.DispatchQueue.main.sync→async(you can't block main waiting for an async completion).fun logout(promise: Promise)resolving from the SDK callback.logout()typedPromise<void>.Compatibility
export function logout()alreadyreturns the bridge call, so existing callers that ignore the return value are unaffected; callers can nowawaitit. The iOS completion is success-only, so there is no reject path.Validation
Running in production QA via patch-package (iOS half) since June across a 50-target workspace: app-level logout flows
await logout()and then tear down safely, with the final state event guaranteed delivered first. Android change compiles againstcom.frontegg.sdk:android1.3.35 (callback parameter has a default, so the SDK call is source-compatible).