Fix deferred authentication callback bug in React Native Android#2863
Merged
wmathurin merged 2 commits intoforcedotcom:devfrom Apr 9, 2026
Merged
Conversation
Store authentication callbacks across activity lifecycle to prevent loss during OAuth flow. When authenticate() is called from React Native bridge, the activity pauses to launch OAuth browser, then resumes after completion. Previously, callbacks were lost during this pause/resume cycle. Changes: - Add instance variables to store pending callbacks - Store callbacks in authenticate() before OAuth flow - Invoke stored callbacks in onResume() after OAuth completes - Clear callbacks after invocation or on auth failure This fixes the issue where ReactNativeDeferredTemplate would show the welcome screen after successful OAuth instead of loading contacts.
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## dev #2863 +/- ##
============================================
- Coverage 64.90% 64.90% -0.01%
- Complexity 2973 2974 +1
============================================
Files 222 222
Lines 17437 17449 +12
Branches 2487 2489 +2
============================================
+ Hits 11318 11325 +7
- Misses 4916 4920 +4
- Partials 1203 1204 +1
🚀 New features to boost your workflow:
|
…enticated When authenticate() is called and the user is already logged in, the authenticatedRestClient callback is invoked immediately without triggering an activity pause/resume cycle. Previously, callbacks were only invoked in onResume(), which is not called in this scenario, causing callbacks to never be invoked. The fix ensures authenticatedRestClient() always invokes pending callbacks immediately when a RestClient is obtained. For OAuth flows, either authenticatedRestClient() or onResume() runs first (race condition) - whichever runs first invokes callbacks and clears them, preventing double invocation. This fix enables deferred authentication patterns in React Native where authenticate() can be called multiple times without triggering OAuth if already authenticated.
brandonpage
approved these changes
Apr 9, 2026
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:
Callbacks from
authenticate()were lost during OAuth flow when the activity paused for the OAuth browser and resumed after completion.Solution:
authenticate()before OAuth flowauthenticatedRestClient()(always runs) andonResume()(OAuth flow only)