-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Symbolicate unhandled promise rejections #40914
Changes from 11 commits
8d1ce80
cb897d0
c488217
516deee
ff6be9c
c460d5f
a54fd6b
2a8a491
352ab9f
07a48c2
1443452
e5eed45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
|
||
import typeof {enable} from 'promise/setimmediate/rejection-tracking'; | ||
|
||
const LogBox = require('./LogBox/LogBox').default; | ||
|
||
let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = { | ||
allRejections: true, | ||
onUnhandled: (id, rejection = {}) => { | ||
|
@@ -22,7 +24,26 @@ let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = { | |
// $FlowFixMe[method-unbinding] added when improving typing for this parameters | ||
message = Error.prototype.toString.call(rejection); | ||
const error: Error = (rejection: $FlowFixMe); | ||
stack = error.stack; | ||
|
||
const warning = | ||
`Possible Unhandled Promise Rejection (id: ${id}):\n` + | ||
`${message ?? ''}\n` + | ||
(stack == null ? '' : stack); | ||
|
||
// Print pretty unhandled rejections while on DEV | ||
if (__DEV__) { | ||
LogBox.addLog({ | ||
level: 'warn', | ||
message: {content: warning, substitutions: []}, | ||
componentStack: [], | ||
stack: error.stack, | ||
category: 'possible_unhandled_promise_rejection', | ||
}); | ||
|
||
return; | ||
} else { | ||
console.warn(warning); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We never write to And I think this will log twice in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, reverted the double warning and just handled the special case while on dev |
||
} else { | ||
try { | ||
message = require('pretty-format')(rejection); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use import instead of require here