Skip to content
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: Fix unhandled promise rejections not being tracked #1367

Merged
merged 6 commits into from
Mar 1, 2021

Conversation

jennmueng
Copy link
Member

@jennmueng jennmueng commented Mar 1, 2021

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Because of a version mismatch in the Promise version used in react-native and fbjs the promise patching we perform is patching the incorrect one, so the hacky fix is to overwrite global promise's methods (if they exist).

const _onHandle = Promise._onHandle ?? Promise._Y;
const _onReject = Promise._onReject ?? Promise._Z;
if (
Promise !== _global.Promise &&
typeof _onHandle !== "undefined" &&
typeof _onReject !== "undefined"
) {
if ("_onHandle" in _global.Promise && "_onReject" in _global.Promise) {
_global.Promise._onHandle = _onHandle;
_global.Promise._onReject = _onReject;
} else if ("_Y" in _global.Promise && "_Z" in _global.Promise) {
_global.Promise._Y = _onHandle;
_global.Promise._Z = _onReject;
}
}

💡 Motivation and Context

Fixes #1077

💚 How did you test it?

Added a new e2e test for unhandled promise rejections. Ran iOS locally but please wait for it to run CI on this PR to confirm.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • All tests passing
  • No breaking changes

🔮 Next steps

We should add a matrix to our e2e CI to test on multiple react native versions as although the code block shown in the description is very defensive to prevent issues, we should still have a way to make sure.

@jennmueng jennmueng marked this pull request as ready for review March 1, 2021 11:44
@jennmueng jennmueng requested a review from HazAT as a code owner March 1, 2021 11:44
@jennmueng jennmueng requested review from bruno-garcia and a team March 1, 2021 11:44
@jennmueng jennmueng changed the title fix: Fix unhandle promise rejections not being tracked fix: Fix unhandled promise rejections not being tracked Mar 1, 2021
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.

Unhandled promises are not logged at all (iOS and Android)
2 participants