Skip to content

fix(auth, android): handle native exception in signInWithEmailLink #8502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025

Conversation

mikehardy
Copy link
Collaborator

Description

@Willham12 pointed out multiple problems with our sign in link handling, and even submitted a PR that handled part of the problem already - this PR handles the remaining two aspects of the problem - a docs update and a native error handling fix

Specifically, the native android signInWithEmailLink method throws an error outside it's Task continuation failure handling, which was unexpected and unhandled in our code. This PR handles that correctly now

Related issues

Release Summary

two conventional commits ready for a rebase and a semantic release

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
    • Other (macOS, web)
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

Subtle to fix, but correctness was enforced because I started it by adding an e2e test and then made our code meet the test expectations

One very subtle thing (for me) is that the new react-native new architecture error handling for bridgeless compatibility mode code is to helpfully package up even unhandled native code exceptions. This changed since the error was logged so I was seeing different behavior in the unhandled exception case - not IllegalArgumentException + crash like expected, but a 'HostError' javascript error object that wasn't from us but was from react-native

Anyway, all handled now


Think react-native-firebase is great? Please consider supporting the project with any of the below:

Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-firebase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 30, 2025 1:15pm

@mikehardy mikehardy changed the title fix(auth, android): correctly handle native exception in signInWithEmailLink fix(auth, android): handle native exception in signInWithEmailLink Apr 29, 2025
@mikehardy mikehardy force-pushed the @mikehardy/sign-in-link-follow-on branch from accf260 to fbfe6e5 Compare April 29, 2025 16:11
the firebase-android-sdk throws an unhandled error if the link is
mal-formed (e.g., missing apiKey param) which bubbled up to javascript
inappropriately making it very hard to handle

now we catch all exceptions and handle correctly with a Promise reject,
and we probe the same with an e2e test
@mikehardy mikehardy force-pushed the @mikehardy/sign-in-link-follow-on branch from fbfe6e5 to 530dd79 Compare April 30, 2025 13:12
@mikehardy
Copy link
Collaborator Author

turns out Other platform also errors if apiKey is missing during sign in - hadn't checked locally since isSignInWithEmailLink doesn't seem to require apiKey. But signInWithEmailLink appears to fail without it. Re-pushed with updated API docs indicating this and e2e test adjusted to handle it

@mikehardy mikehardy added Workflow: Pending Merge Waiting on CI or similar and removed Needs Attention labels Apr 30, 2025
@mikehardy mikehardy merged commit a08580e into main Apr 30, 2025
18 checks passed
@mikehardy mikehardy deleted the @mikehardy/sign-in-link-follow-on branch April 30, 2025 15:49
@mikehardy mikehardy removed the Workflow: Pending Merge Waiting on CI or similar label Apr 30, 2025
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.

[🐛] IllegalArgumentException: Given link is not a valid email link
2 participants