Skip to content

hardcoded 2 second delay before onUnhandled fires #54960

@marcospgp

Description

@marcospgp

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:

  1. Making the delay configurable via options
  2. Reducing the default delay (2s feels excessive in 2025)
  3. 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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions