Skip to content

fix(tracing): Detect expo/fetch behind the Expo Router fetch wrapper - #6965

Open
antonis wants to merge 3 commits into
mainfrom
antonis/expo-router-fetch-detection
Open

antonis wants to merge 3 commits into
mainfrom
antonis/expo-router-fetch-detection

Conversation

@antonis

@antonis antonis commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

isExpoFetchEnabled() checks for the expo.builtin marker on globalThis.fetch. In Expo Router apps, @expo/metro-runtime wraps fetch to support relative URLs, and before 58.0.15 the wrapper dropped that marker. The SDK then misses expo/fetch, so fetch tracing and fetch breadcrumbs stay off by default.

When the marker is missing, isExpoFetchEnabled() now also returns true if:

  • globalThis.fetch has the wrapper's own marker (expo.polyfillFetchWithWindowLocation),
  • the Expo SDK is 56 or later (the first SDK that installs expo/fetch), read from the native ExponentConstants.manifest (a JSON string on Android), and
  • the app hasn't opted out with EXPO_PUBLIC_USE_RN_FETCH. It's read the same way as Expo's own runtime, so both resolve the same value after babel-preset-expo.

If any of these can't be determined, it returns false, which is the previous behavior.

This also applies the expo/fetch HTTP timings default from #6912 to these apps, so traceFetch: true no longer needs enableHTTPTimings: false to avoid leaking listeners.

💡 Motivation and Context

Fixes #6874

💚 How did you test it?

  • Unit tests for isExpoFetchEnabled(): SDK 56/57/58, SDK 55, unknown SDK version, manifest as a JSON string and as invalid JSON, EXPO_PUBLIC_USE_RN_FETCH set to 1, true and 0.
  • Expo sample:
    • Before: a traced fetch produced no http.client span and no fetch breadcrumb.
    • After: one http.client span without HTTP timings, and a fetch breadcrumb.
    • With EXPO_PUBLIC_USE_RN_FETCH=1: one http.client span from XHR and only an xhr breadcrumb (no duplicate).

📝 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

antonis and others added 2 commits October 29, 2026 13:38
@expo/metro-runtime before 58.0.15 wraps fetch in Expo Router apps and
drops the expo.builtin marker. Fall back to the wrapper's own marker on
Expo SDK 56+ unless the app opted out with EXPO_PUBLIC_USE_RN_FETCH.

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

github-actions Bot commented Oct 29, 2026 •

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(tracing): Detect expo/fetch behind the Expo Router fetch wrapper by antonis and claude in #6965
  • fix(android): Restore enableLogs option mapping by antonis and claude in #6967
  • chore(deps): update Wizard to v9.1.0 by github-actions in #6972
  • chore(deps): update Sentry Android Gradle Plugin to v6.25.0 by github-actions in #6971

🤖 This preview updates automatically when you update the PR.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b429007. Configure here.

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Oct 29, 2026
@antonis
antonis marked this pull request as ready for review October 29, 2026 13:01
@antonis
antonis requested review from a team and lucas-zimerman as code owners October 29, 2026 13:01
@antonis
antonis requested review from alwx and buenaflor and removed request for a team October 29, 2026 13:01
@sentry

sentry Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.33.0 (113) 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.

isExpoFetchEnabled() returns false in Expo Router apps because metro-runtime wraps global fetch

1 participant