Skip to content

fix(core): Fall back to Sentry Metro middleware for debug symbolication - #7031

Open
lucas-zimerman wants to merge 2 commits into
mainfrom
lz/fix/4877
Open

lucas-zimerman wants to merge 2 commits into
mainfrom
lz/fix/4877

Conversation

@lucas-zimerman

@lucas-zimerman lucas-zimerman commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds a Sentry-owned symbolication path so DebugSymbolicator no longer depends only on React Native's internal symbolicateStackTrace.

  • Metro middleware: new /__sentry/symbolicate route in createSentryMetroMiddleware. It rewrites the URL to Metro's own /symbolicate (keeping any query string) and hands the request to Metro's handler. The body isn't read by our middleware, so Metro parses it as usual.
  • App side: symbolicateStackTrace in debugsymbolicatorutils.ts still tries React Native's version first. If it's missing or throws or rejects, it POSTs the stack to ${devServer.url}__sentry/symbolicate using the existing un-instrumented XHR (no breadcrumbs or spans). Failures reject into DebugSymbolicator's existing catch, so nothing reaches the app.
  • Constants: SENTRY_SYMBOLICATE_REQUEST_PATH and METRO_SYMBOLICATE_REQUEST_PATH added to metro/constants.ts. The hard-coded __sentry/context path now uses its constant.

No public API changes (API report unchanged).

💡 Motivation and Context

React Native is removing deep imports like react-native/Libraries/Core/Devtools/* from its public API (RFC #894). RN 0.88 already warns at runtime:

Deep imports from the 'react-native' package are deprecated ('react-native/Libraries/Core/Devtools/parseErrorStack')

parseErrorStack already has a Sentry-parser fallback (#5946). This adds the equivalent for symbolicateStackTrace, the second item of #4877.

Refs #4877

💚 How did you test it?

  • Unit tests: 8 new tests for the app-side fallback (React Native path used when available, fallback on throw and reject, non-200, invalid JSON, network error, bundle not from Metro, Devtools missing) and 2 for the middleware URL forwarding. yarn test (SDK + tools), lint, circularDepCheck, build:sdk and api-report:check pass.
  • Route check against Metro v0.87.1: posted the same bundle frame to /symbolicate and /__sentry/symbolicate; the responses are byte-identical.
  • End-to-end on the RN sample (Android emulator, RN 0.88.1, New Architecture): temporarily made React Native's symbolicateStackTrace throw and tapped "Capture exception". The SDK logged the fallback warning and the top frame came back as src/Screens/ErrorsScreen.tsx:79:45 Button.props.onPress, in-app, with the correct context_line. With the change reverted, the normal path still sends the event with no fallback warning.
  • Not run on iOS. The change is JS + Metro only, so the path is shared.

📝 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

  • rnlibraries.ts still requires react-native/Libraries/Core/Devtools/{parseErrorStack,symbolicateStackTrace,getDevServer}. Once React Native stops resolving them, Metro could fail to bundle on the unresolved require. A follow-up could make the Sentry parser and /__sentry/symbolicate the defaults and drop those imports.
  • getDevServer (used by both fallbacks), Libraries/Promise, Libraries/Utilities/PolyfillFunctions and Libraries/NativeComponent/NativeComponentRegistry are also deep imports.

lucas-zimerman and others added 2 commits November 13, 2026 16:49
React Native is deprecating deep imports such as
`react-native/Libraries/Core/Devtools/symbolicateStackTrace` (RN 0.88 already
warns at runtime). Add a `/__sentry/symbolicate` route to the Sentry Metro
middleware that forwards to Metro's own `/symbolicate` endpoint, and use it in
`DebugSymbolicator` when RN's `symbolicateStackTrace` is unavailable or fails.

Refs #4877

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

⚪ None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(core): Fall back to Sentry Metro middleware for debug symbolication by lucas-zimerman and claude in #7031
  • build(deps): Bump addressable to 2.9.2 in macOS sample to resolve advisories by antonis and claude in #7029
  • chore(deps): bump addressable from 2.9.0 to 2.9.1 in /samples/react-native-tvos by dependabot in #7028
  • chore(deps): bump addressable from 2.9.0 to 2.9.1 in /samples/react-native-visionos by dependabot in #7026
  • chore(deps): bump addressable from 2.9.0 to 2.9.1 in /samples/react-native by dependabot in #7027
  • chore(deps): update Sentry Android Gradle Plugin to v6.27.0 by github-actions in #7025
  • build(deps): Bump basic-ftp to 6.2.6 to resolve DoS advisory by antonis and claude in #7024
  • build(deps): Bump fast-xml-parser to 5.12.0 to resolve ReDoS advisory by antonis and claude in #7022
  • chore(deps): bump node-forge from 1.4.2 to 1.4.3 by dependabot in #7023

🤖 This preview updates automatically when you update the PR.

@lucas-zimerman lucas-zimerman added the ready-to-merge Triggers the full CI test suite label Nov 13, 2026
@lucas-zimerman
lucas-zimerman marked this pull request as ready for review November 13, 2026 16:53
@sentry

sentry Bot commented Nov 13, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.35.0 (115) Release

⚙️ sentry-react-native Build Distribution Settings

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant