Skip to content

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 a team and bruno-garcia 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)

3 participants