Skip to content

fix(core): Put native linked errors before the original exception - #7179

Merged
alwx merged 4 commits into
getsentry:mainfrom
lazerg:fix/native-linked-errors-order
Dec 4, 2026
Merged

alwx merged 4 commits into
getsentry:mainfrom
lazerg:fix/native-linked-errors-order

Conversation

@lazerg

@lazerg lazerg commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

nativeLinkedErrorsIntegration now puts the linked errors before the original exception, oldest first, so the original exception stays last in exception.values like linkedErrorsIntegration in @sentry/core does. debugSymbolicatorIntegration matched the cause chain to exception.values from the front, so I changed it to match from the end, otherwise in dev the symbolicated frames would land on the wrong exception.

💡 Motivation and Context

Fixes #7178

Sentry treats the last exception in values as the main one. Because the causes were appended after the original exception, an error like new Error('Request failed', { cause }) got the cause's type and message as the issue title.

💚 How did you test it?

Added a unit test with a two-level JS cause chain and updated the existing native linked errors and debug symbolicator tests to the new order. yarn jest and yarn lint pass in packages/core.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 6cec49c.

Main concerns: reach, data sent to Sentry.

This label is a hint for reviewers, not an approval.

@lazerg

lazerg commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

The changelog-preview failure is not from this change. The workflow does not check out code from fork PRs, so it fails on every fork PR.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Dec 4, 2026
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
@antonis

antonis commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

@sentry-junior verify

@sentry-junior

sentry-junior Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Experimental end-to-end verification by Junior, run on an Android emulator in CI. A maintainer decides what it means.

fix(core): Put native linked errors before the original exception: Verified on Android

Claim (from #7178): a JS error's cause is appended after the original exception, so the cause is last in exception.values and becomes the main exception. Without the PR the event's exceptions were [Error, TypeError] (the TypeError cause last); with it they were [TypeError, Error], with the original Error last.

Side Run id Event Evidence
Without the PR gh47313065547-without 09b6822b892046b081fce87536d66bf7 exception.values types [Error, TypeError]; last (main) is TypeError, the cause
With the PR gh47313065547-with c7fc19b63d044e41ac7006ca41722f2d exception.values types [TypeError, Error]; last (main) is Error, the original

The event links need access to the sentry-sdks org.

  • Same on both: the two exceptions are the same list in reverse order; every exception's frames (filename, function, in_app: 11 app:///index.android.bundle frames ending in onPress, all in_app) are identical; platform javascript; verify.pr 7179; processing errors js_no_source on both.
  • Built from: 405d56c, with packages/core/src/js/integrations/debugsymbolicator.ts and packages/core/src/js/integrations/nativelinkederrors.ts reversed for the without side; bundles differ, native code identical (same dex).
  • Sample change: added "Capture exception with TypeError cause" (an Error whose cause is a TypeError) on verify/pr-7179 only. The existing "Capture exception with cause" uses Error for both, which the fetched fields can't tell apart.
  • Flow: pr-7179-typeerror-cause.yml on verify/pr-7179
  • Not covered: iOS (affected, not run), the Old Architecture, debug builds (the debugSymbolicator change only runs in dev), Expo, other React Native versions, native linked errors (Java/ObjC causes, nativeStackAndroid), the issue title and grouping as Sentry computes them, a two-level cause chain, the no-cause path.
  • Problems: none

Asked by antonis. Run: https://github.com/getsentry/sentry-react-native/actions/runs/47313065547

via Antonis Lilis.

Comment thread CHANGELOG.md Resolved

@antonis antonis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🚀

Thanks for the fix @lazerg, and for the clear issue write-up 🙇

Verified end to end without and with the change:

Scenario Without With
Error with cause Error: Cause of captured exception Error: Captured exception
Sentry.ErrorBoundary React ErrorBoundary Invariant Violation: … Invariant Violation: …
nativeStackAndroid rejection [JS, Java] [Java, JS]

Together with the CI verification above, this confirms the original exception now stays last in exception.values aligning with the spec.

@antonis antonis removed the ready-to-merge Triggers the full CI test suite label Dec 4, 2026
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 4, 2026
@antonis
antonis enabled auto-merge (squash) December 4, 2026 10:48
@antonis
antonis disabled auto-merge December 4, 2026 10:49
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Dec 4, 2026
@alwx
alwx merged commit e05993f into getsentry:main Dec 4, 2026
102 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nativeLinkedErrorsIntegration appends linked errors after the original exception, so the cause becomes the issue title

3 participants