-
Notifications
You must be signed in to change notification settings - Fork 25k
Description
Description
Problem
React Native's unhandled promise rejection handler has a hardcoded 2-second delay before onUnhandled fires. This causes a significant UX problem: users wait 2 seconds before seeing any error feedback.
Root Cause
This is not a Hermes issue - it's in the promise npm package that React Native uses for rejection tracking.
From promise/src/rejection-tracking.js:
setTimeout(
onUnhandled.bind(null, promise._rejectionId),
matchWhitelist(err, DEFAULT_WHITELIST) ? 100 : 2000
)- 100ms for ReferenceError, TypeError, RangeError (programmer bugs)
- 2000ms for everything else (to allow late
.catch()attachments)
From the npm docs:
"To reduce the chance of false-positives there is a delay of up to 2 seconds before errors are logged."
Impact
Most app errors (network failures, API errors, business logic) get the 2-second delay, not the 100ms path. This makes error handling feel sluggish.
Suggested Improvement
Consider:
- Making the delay configurable via options
- Reducing the default delay (2s feels excessive in 2025)
- Documenting this behavior prominently (it's buried in the npm readme)
Workaround
Intercept errors before they become "unhandled rejections." For example, tRPC's MutationCache.onError or similar framework-level hooks fire immediately.
References
- Source code: https://github.com/then/promise/blob/master/src/rejection-tracking.js
- npm package: https://www.npmjs.com/package/promise
Steps to reproduce
see above
React Native Version
latest
Affected Platforms
Runtime - iOS
Output of npx @react-native-community/cli info
n/a
Stacktrace or Logs
n/a
MANDATORY Reproducer
n/a
Screenshots and Videos
No response