Log unhandled promise rejections to the server#46173
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
@hayata-suenaga Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
I have read the CLA Document and I hereby sign the CLA |
|
@Kureev thanks for the PR! A few things:
Thanks! |
6245265 to
4c8e2c2
Compare
|
I will review this (slack) |
|
@Kureev , can you read this slack convo about native platforms once you're online thanks! https://expensify.slack.com/archives/C02NK2DQWUX/p1722016873307739 |
|
@Kureev are there any testing steps involved? |
Unfortunately, I don't have access to this thread
Yes: as I mentioned in the PR description, I tested it on iOS device and in Chrome by throwing an unhandled rejection |
Oops my bad, I will post some comments from there:
Can you confirm whether the error is also handled in native platform as we have a different file altogether for it @Kureev |
How should i do that? is there any change in code which i can make for the error to occur? asking cause i'm not really sure how we can make that error to occur |
|
Also, @puneetlath can you ask for my review here, this is not in my K2 currently |
|
Would you like me to send the event to crashlytics on the native platform? |
should do the trick |
|
@allgandalf were you able to get your questions answered and test the functionality? I cc'd you into the Slack thread, so you should have access to it now if needed. |
|
yes @puneetlath , I did see the ping, having dinner, should be back in an hour to review this,we will get this checked and merged today for sure 🤝 |
|
testing now 🟢 |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb Safari |
| window.addEventListener('unhandledrejection', onUnhandledRejection); | ||
| return () => window.removeEventListener('unhandledrejection', onUnhandledRejection); |
There was a problem hiding this comment.
Android as well as iOS are not recognizing window:
Also if i build the apps, then they would build successfullly but do not open, they crash after sometime, can you reproduce that @Kureev ? let me know if you need any additional information thanks
There was a problem hiding this comment.
Yeah, can reproduce it now (after adding code to the .native.tsx file), thank you for this report. Testing the fix atm. Will update this PR accordingly
There was a problem hiding this comment.
so, there is a slight issue with the fix here. It isn't so trivial to handle unhandled promise rejections in RN. It seems that right now React Native uses https://www.npmjs.com/package/promise package and in particular onUnhandled to integrate unhandled promise rejections into the LogBox:
- https://github.com/facebook/react-native/blob/bd51fcd58e19cf48f952c6ee6866d43ce438952b/packages/react-native/Libraries/Promise.js#L19
- https://github.com/facebook/react-native/blob/bd51fcd58e19cf48f952c6ee6866d43ce438952b/packages/react-native/Libraries/promiseRejectionTrackingOptions.js#L4
That said, I can do the same, but it poses some risks if RN team changes the internal approach. Would you like me to go down this way?
There was a problem hiding this comment.
We agreed to not to implement .native counterpart and keep the solution to web only: https://expensify.slack.com/archives/C05LX9D6E07/p1722343972517359?thread_ts=1721217121.843389&cid=C05LX9D6E07
|
Caution To anyone in future looking to implement the same for native platforms, We didn't implement in the current PR because of the reason mentioned here, we came to the conclusion that we should not add this change to native based on the slack conversation of this thread. Hope we find a solution for this soon |
allgandalf
left a comment
There was a problem hiding this comment.
@puneetlath , as this is the first PR of the author the other workflows are not enabled for them, idr how we enable them, please don't merge yet as we need the pending tests to pass, thanks
|
🎯 @allgandalf, thanks for reviewing and testing this PR! 🎉 An E/App issue has been created to issue payment here: #46498. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/puneetlath in version: 9.0.15-0 🚀
|
|
you bet ! 😎 |
|
🚀 Deployed to production by https://github.com/roryabraham in version: 9.0.15-9 🚀
|






Details
According to our conversation with @puneetlath here, I composed a small PR to add additional logging for unhandled promise rejections to the error boundary.
Tests
Manually tested that the unhandled promise rejection error is sent to the server:
Manually tested on iOS app
Verify that no errors appear in the JS console
Offline tests
N/A
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop