-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(dynamic-links, android): check for null currentIntent in getInitialLink to avoid crash #5662
fix(dynamic-links, android): check for null currentIntent in getInitialLink to avoid crash #5662
Conversation
… getInitialLink() of ReactNativeFirebaseDynamicLinksModule.java
This pull request is being automatically deployed with Vercel (learn more). react-native-firebase-next – ./website_modular🔍 Inspect: https://vercel.com/invertase/react-native-firebase-next/BtuWpJ9r9MNocVvs9qMeXgCr78Kh [Deployment for d7c863e canceled] react-native-firebase – ./🔍 Inspect: https://vercel.com/invertase/react-native-firebase/7fR685ET1iSZgu5BLd4rkREdLpV6 |
Codecov Report
@@ Coverage Diff @@
## master #5662 +/- ##
============================================
+ Coverage 53.26% 53.64% +0.39%
Complexity 632 632
============================================
Files 208 208
Lines 10084 10087 +3
Branches 1543 1544 +1
============================================
+ Hits 5370 5410 +40
+ Misses 4427 4393 -34
+ Partials 287 284 -3 |
This actually looks like an upstream bug. We check for null before de-referencing anything on the Intent, though we do pass it to the underlying firebase-android-sdk API. We haven't seen this before as a reported issue ever though, and I haven't experienced it in my work projects, under what conditions does it happen? Did it just start happening? The upstream API is specifically documented as being able to tolerate null (emphasis mine):
The source code is a bit of comedy though, examine the javadoc (which generated the doc I quote and link above) in contrast to the And indeed, here's your crash: Looks like the null check is necessary, but either the documentation or code needs an update. marking this for merge after CI passes since it's definitely necessary with current + prior (up to 2 years minimum, according to git blame) dynamic links implementation in firebase-android-sdk Thanks for the patch! |
Oh - until there's a release here (not sure when I'll do the next one - need to see if there's anything else queued up...) you should check the artifacts link from the create test patches action - we generate a patch-package set for every PR, since it's otherwise a real pain to integrate stuff from our monorepo structure. That makes it trivial |
…micLink firebase-android-sdk requires a `@NonNull` Intent argument to the `getDynamicLink(Intent)` call, despite the documentation indicating otherwise Related firebase/firebase-android-sdk#2336 Related invertase/react-native-firebase#5662
In our case, it's a weird interaction between this library and 2 others that we are using. We have a CodePush.restartApp() call, which reloads the JS. We are also using 'react-native-receive-sharing-intent' library, which checks for received files in a useEffect in the same file where we have the dynamic link implementation. Side note -- I signed the CLA but it still says it's not signed. Not sure what to do about that |
That makes sense with regard to the reproduction case you have - that certainly does sound rare, and perhaps sort of a bug in it's own right but there's no excuse for a native crash, this patch is good no matter what. The CLA issue is almost always because the commit email address is different than the github / CLA address. The details link has some info on it but usually you just need to make sure all the email addresses involved are associated as aliases in your github account settings. Sorry for the hassle there, seems a bit much for a small patch but it's still necessary Thanks! |
This has some unrelated CI issue, I just re-kicked Android E2E CI check to make sure but it should pass. I have another crash fix queued up now, will release inside an hour or two |
Description
If a null intent is passed to
FirebseDynamicLinks.getInstance().getDynamicLink(currentIntent)
, it crashes with the following error:Attempt to invoke virtual method 'java.lang.String android.content.Intent.getDataString()' on a null object reference.
To avoid that, I added a check for null currentIntent. Of it's null, resolve the promise and return early (same as the check above it for null currentActivity).
Checklist
Android
(resolves a crash that was only happening on Android)iOS
e2e
tests added or updated inpackages/\*\*/e2e
jest
tests added or updated inpackages/\*\*/__tests__
🔥