Skip to content

Report error cause with native stacktrace for Turbo Module exceptions#2686

Merged
hamudi-ahmed merged 3 commits intonextfrom
PLAT-12194/rn-native-stack-traces
Mar 3, 2026
Merged

Report error cause with native stacktrace for Turbo Module exceptions#2686
hamudi-ahmed merged 3 commits intonextfrom
PLAT-12194/rn-native-stack-traces

Conversation

@hamudi-ahmed
Copy link
Copy Markdown
Contributor

@hamudi-ahmed hamudi-ahmed commented Feb 27, 2026

Goal

In The New Architecture, when an unhandled exception occurs in a Turbo Module method, React Native throws a JS error with a cause property containing the native exception class, error message and stacktrace.

Although the JS SDK supports error causes, these native causes are not parsed correctly in events as they don't contain valid JS stacktraces (the cause stack is reported as stackElements on Android and stackSymbols/stackReturnAddresses on iOS) - so we end up reporting events with an empty stacktrace in the 'Caused by' error.

This PR fixes the error reporting for these cases, so that native 'Caused by' errors are reported correctly with a full native stacktrace while maintaining backwards compatibility with native stack handling for Old Architecture.

(Note: on iOS, exceptions in async Turbo Module methods result in a native crash that is detected by the Cocoa SDK, so this does not apply in those cases)

Changeset

  • Updated the native stack handling in delivery-react-native to extract the nativeStack property for native error causes.

  • Updated BugsnagEventDeserializer.m in the iOS native module to correctly handle events containing multiple errors (the equivalent changes for Android were released in v6.22.0 of bugsnag-plugin-react-native)

Testing

Added new unit test and e2e test cases

@hamudi-ahmed hamudi-ahmed force-pushed the PLAT-12194/rn-native-stack-traces branch from d364136 to e4d896d Compare February 27, 2026 13:29
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 27, 2026

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 50.69 kB 15.03 kB
After 50.69 kB 15.03 kB
± No change No change

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against e32a479

@hamudi-ahmed hamudi-ahmed force-pushed the PLAT-12194/rn-native-stack-traces branch from e4d896d to e32a479 Compare February 27, 2026 14:14
@hamudi-ahmed hamudi-ahmed marked this pull request as ready for review February 27, 2026 14:58
@hamudi-ahmed hamudi-ahmed requested a review from lemnik February 27, 2026 14:58
Copy link
Copy Markdown
Contributor

@lemnik lemnik left a comment

Choose a reason for hiding this comment

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

LGTM

@hamudi-ahmed hamudi-ahmed merged commit 843442f into next Mar 3, 2026
82 checks passed
@hamudi-ahmed hamudi-ahmed deleted the PLAT-12194/rn-native-stack-traces branch March 3, 2026 15:43
SB-priyankap pushed a commit that referenced this pull request Mar 11, 2026
…o module exceptions (#2686)

* feat(react-native): native stacktraces for turbo module exceptions

* test(react-native): add e2e tests for turbo module mixed stacktraces

* docs: add changelog entry
@SB-priyankap SB-priyankap mentioned this pull request Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants