Skip to content

fix(react-native): skip duplicate native report for fatal unhandled JS errors on iOS - #380

Merged
KishanPRao merged 1 commit into
mainfrom
feature/react-native-ios-double-report
Jul 30, 2026
Merged

fix(react-native): skip duplicate native report for fatal unhandled JS errors on iOS#380
KishanPRao merged 1 commit into
mainfrom
feature/react-native-ios-double-report

Conversation

@KishanPRao

Copy link
Copy Markdown
Contributor

Summary

On iOS a fatal unhandled JS error was reported twice (a JS "Unhandled exception" plus a redundant native "Crash"); this drops the native duplicate while keeping the JS report.
Adds a jest test for the marker, and makes the example's "Throw an unhandled error" button a real fatal.

Changes

  • UnhandledExceptionHandler.ts: on a fatal error, call CrashReporter.markFatalError() before chaining the previous global handler.
  • CrashReporter.ts: add an optional-chained static markFatalError(), a no-op where the native binding is absent (Android).
  • BacktraceReactNative.mm: export markFatalError as a blocking-synchronous method so the flag is set before RCTFatal.
  • BacktraceCrashReporter.h: declare markJsFatalError.
  • BacktraceCrashReporter.mm: stash a jsFatal flag in the crash's PLCrashReporter customData, purge that pending report on next launch, self-clear the flag after 2s.
  • unhandledExceptionHandlerTests.spec.ts: cover markFatalError firing on a fatal error and not on a non-fatal one.
  • actions.ts: make "Throw an unhandled error" a real fatal via a deferred throw instead of an async rejection.

Note

The 2s self-clear calls saveReportData on the main queue, which can race the module-thread attribute setters; harmless (a stale attribute at worst), can be serialized in a follow-up.

ref: BT-7403

@KishanPRao
KishanPRao requested a review from melekr July 30, 2026 16:55
@KishanPRao KishanPRao self-assigned this Jul 30, 2026
@KishanPRao KishanPRao added the bug Something isn't working label Jul 30, 2026
@KishanPRao
KishanPRao marked this pull request as draft July 30, 2026 16:55

@melekr melekr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@KishanPRao
KishanPRao marked this pull request as ready for review July 30, 2026 17:13
@KishanPRao KishanPRao changed the title fix(react-native): skip duplicate native report for fatal unhandled js errors on iOS fix(react-native): skip duplicate native report for fatal unhandled JS errors on iOS Jul 30, 2026
@KishanPRao
KishanPRao merged commit c5fcb94 into main Jul 30, 2026
6 checks passed
@KishanPRao
KishanPRao deleted the feature/react-native-ios-double-report branch July 30, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants