Skip to content

Commit

Permalink
feat: onUnhandledRejection 支持core-js promise polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
mackwang committed Jan 17, 2025
1 parent d04870a commit 581523c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/core/src/platform/env/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,15 @@ function initGlobalErrorHandling () {
}
}

// 支持 core-js promise polyfill
const oldOnUnhandledRejection = global.onunhandledrejection
global.onunhandledrejection = function onunhandledrejection (event) {
// event = { promise, reason }
rejectionTrackingOptions.onUnhandled(null, event.reason)
oldOnUnhandledRejection.apply(this, event)
}
if (global?.HermesInternal?.hasPromise?.()) {
global.HermesInternal?.enablePromiseRejectionTracker?.(rejectionTrackingOptions)
global.HermesInternal.enablePromiseRejectionTracker?.(rejectionTrackingOptions)
} else {
require('promise/setimmediate/rejection-tracking').enable(rejectionTrackingOptions)
}
Expand Down

0 comments on commit 581523c

Please sign in to comment.