Skip to content

fix(react-native): reject instead of crashing when no Activity on Android (FR-25939) - #94

Closed
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/rn-android-currentactivity-npe
Closed

fix(react-native): reject instead of crashing when no Activity on Android (FR-25939)#94
dianaKhortiuk-frontegg wants to merge 1 commit into
masterfrom
fix/rn-android-currentactivity-npe

Conversation

@dianaKhortiuk-frontegg

Copy link
Copy Markdown
Collaborator

FR-25939 — Android currentActivity!! NPE crash

login, directLoginAction, loginWithPasskeys and registerPasskeys used currentActivity!!. When currentActivity is null (app backgrounded / activity recreated) this throws KotlinNullPointerExceptionapp crash instead of a recoverable rejection. stepUp and openAdminPortal already null-check and reject("NO_ACTIVITY", …).

Fix

Extract a top-level withActivityOrReject(activity, promise, block) that rejects with NO_ACTIVITY and skips the block when the activity is null, and route the four remaining methods through it.

Tests

WithActivityOrRejectTest: null activity → rejects NO_ACTIVITY, block not run, promise not resolved. RED → GREEN via the example-app Gradle harness (:frontegg_react-native:testDebugUnitTest).

Note

The stale branch fix/android-currentactivity-stepup-adminportal (duplicates the already-merged stepUp/adminPortal fix and does not cover these four sites) can be deleted.

…roid (FR-25939)

login/directLoginAction/loginWithPasskeys/registerPasskeys used currentActivity!!, which
throws KotlinNullPointerException and crashes the app when currentActivity is null (app
backgrounded / activity recreated). Extract a top-level withActivityOrReject(activity,
promise, block) that rejects with NO_ACTIVITY and skips the block — matching stepUp and
openAdminPortal, which already null-check — and route the four sites through it.

Test: WithActivityOrRejectTest (RED->GREEN).
@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