Skip to content

fix(tracing): Enable fetch instrumentation when expo/fetch is active#6226

Draft
antonis wants to merge 3 commits into
mainfrom
antonis/fix-expo-fetch-instrumentation
Draft

fix(tracing): Enable fetch instrumentation when expo/fetch is active#6226
antonis wants to merge 3 commits into
mainfrom
antonis/fix-expo-fetch-instrumentation

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented May 28, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Expo SDK 56 replaces globalThis.fetch with a native implementation (expo/fetch) that bypasses XMLHttpRequest entirely. The SDK disabled fetch tracing on native (traceFetch: false) because RN's default fetch is a whatwg-fetch polyfill over XHR — enabling both would cause duplicate spans. However, with expo/fetch active, XHR instrumentation never fires for network requests, resulting in:

  • Missing http.client spans
  • Missing fetch breadcrumbs
  • No sentry-trace / baggage headers injected (broken distributed tracing)

Changes

environment.ts — Added isExpoFetchEnabled() detection function that checks for Symbol.for('expo.builtin') on globalThis.fetch, which Expo's installGlobal sets on all replaced globals.

reactnativetracing.tstraceFetch now defaults to true when expo/fetch is detected. Detection runs inside the factory function (not at module level) to ensure Expo's polyfills are installed before detection.

breadcrumbs.ts — Fetch breadcrumbs now default to true when expo/fetch is detected. Updated JSDoc for both fetch and xhr options to reflect the new behavior.

Behavior matrix

Environment traceFetch traceXHR fetch breadcrumbs
Standard RN (no expo) false true false
Expo ≤55 false true false
Expo 56+ (expo/fetch active) true true true
Expo 56+ with EXPO_PUBLIC_USE_RN_FETCH=1 false true false
Web true true true
User explicit options Always respected Always respected Always respected

💡 Motivation and Context

Fixes #6225
Part of #6212

Workaround (for users before this fix ships)

Sentry.init({
  integrations: [
    Sentry.reactNativeTracingIntegration({ traceFetch: true }),
    Sentry.breadcrumbsIntegration({ fetch: true }),
  ],
});

Or opt out of expo/fetch: EXPO_PUBLIC_USE_RN_FETCH=1 in .env.

💚 How did you test it?

  • Unit tests for isExpoFetchEnabled() — 4 cases (undefined fetch, plain fetch, expo/fetch with symbol, symbol present but false)
  • Integration tests for traceFetch default — 4 cases (mobile without expo/fetch, mobile with expo/fetch, web, user explicit override)
  • Integration tests for breadcrumbs — 2 cases (expo/fetch enables fetch breadcrumbs, explicit fetch: false override)
  • All 128 test suites pass (1786 tests)
  • Lint passes

📝 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
  • No breaking changes

🔮 Next steps

Expo SDK 56 replaces globalThis.fetch with a native implementation
(expo/fetch) that bypasses XHR entirely. The SDK disabled fetch tracing
on native because RN's fetch was an XHR polyfill, but this caused
missing HTTP spans, breadcrumbs, and broken distributed tracing with
expo/fetch.

Detect expo/fetch via the Symbol.for('expo.builtin') marker and enable
fetch tracing and breadcrumbs when active.

Fixes #6225

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

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): Enable fetch instrumentation when expo/fetch is active by antonis in #6226
  • fix(ci): Remove @sentry/types from JS SDK updater script by antonis in #6219
  • feat(tracing): Add breadcrumbs for dispatched React Navigation events by antonis in #6218
  • feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation by antonis in #6199
  • chore(e2e): Update Expo sample to SDK 56 by antonis in #6216
  • feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager by alwx in #6182
  • chore(deps): bump getsentry/craft from 2.26.5 to 2.26.6 by dependabot in #6213
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.26.5 to 2.26.6 by dependabot in #6214
  • chore(deps): bump github/codeql-action from 4.35.5 to 4.36.0 by dependabot in #6215
  • fix(ios): Return NO from requiresMainQueueSetup by antonis in #6202
  • fix(tracing): Bound TTID/TTFD to prevent inflated transactions by antonis in #6210
  • feat(core): Add disableAutoUpload option to Expo plugin by antonis in #6195
  • chore(deps): Remove unused @sentry/types dependency by antonis in #6207
  • Correct route and dynamic param extraction for Expo Router (Correct route and dynamic param extraction for Expo Router #6157) by alwx in #6197
  • chore(deps): update CLI to v3.4.3 by github-actions in #6205
  • chore(deps): update Cocoa SDK to v9.14.0 by github-actions in #6204
  • chore(deps): update Maestro to v2.6.0 by github-actions in #6198
  • chore(deps): bump js-cookie from 3.0.5 to 3.0.7 by dependabot in #6203
  • chore(deps): bump @tootallnate/once from 2.0.0 to 2.0.1 by dependabot in #6206
  • chore(deps): update Sentry Android Gradle Plugin to v6.8.1 by github-actions in #6196
  • feat(core): Expose pauseAppHangTracking and resumeAppHangTracking APIs by antonis in #6192

🤖 This preview updates automatically when you update the PR.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented May 28, 2026

@sentry review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 c995fd1. Configure here.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis antonis added the ready-to-merge Triggers the full CI test suite label May 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3844.02 ms 1220.59 ms -2623.43 ms
Size 5.15 MiB 6.69 MiB 1.54 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0b5120f+dirty 3838.39 ms 1232.91 ms -2605.48 ms
4e0ba9c+dirty 3839.22 ms 1221.06 ms -2618.16 ms
0d9949d+dirty 1211.38 ms 1219.67 ms 8.29 ms
bc0d8cf+dirty 3830.33 ms 1220.52 ms -2609.81 ms
c151573+dirty 3841.06 ms 1232.13 ms -2608.93 ms
7d6fd3a+dirty 1223.29 ms 1229.57 ms 6.28 ms
a3265b6+dirty 3826.31 ms 1207.87 ms -2618.44 ms
5c1e987+dirty 1204.30 ms 1222.15 ms 17.85 ms
5125c43+dirty 3846.45 ms 1221.12 ms -2625.32 ms
5569641+dirty 3839.22 ms 1231.30 ms -2607.91 ms

App size

Revision Plain With Sentry Diff
0b5120f+dirty 5.15 MiB 6.68 MiB 1.53 MiB
4e0ba9c+dirty 5.15 MiB 6.67 MiB 1.51 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
bc0d8cf+dirty 5.15 MiB 6.67 MiB 1.51 MiB
c151573+dirty 5.15 MiB 6.68 MiB 1.53 MiB
7d6fd3a+dirty 3.38 MiB 4.77 MiB 1.39 MiB
a3265b6+dirty 5.15 MiB 6.68 MiB 1.53 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
5125c43+dirty 5.15 MiB 6.68 MiB 1.53 MiB
5569641+dirty 5.15 MiB 6.67 MiB 1.51 MiB

@sentry
Copy link
Copy Markdown

sentry Bot commented May 28, 2026

📲 Install Builds

Android

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

⚙️ sentry-react-native Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3826.85 ms 1217.13 ms -2609.72 ms
Size 5.15 MiB 6.69 MiB 1.54 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0b5120f+dirty 3843.24 ms 1223.00 ms -2620.24 ms
4e0ba9c+dirty 3856.39 ms 1234.44 ms -2621.95 ms
0d9949d+dirty 1203.94 ms 1202.27 ms -1.67 ms
bc0d8cf+dirty 3834.64 ms 1223.91 ms -2610.73 ms
c151573+dirty 3835.64 ms 1216.10 ms -2619.53 ms
7d6fd3a+dirty 1210.89 ms 1217.63 ms 6.74 ms
a3265b6+dirty 3844.26 ms 1235.60 ms -2608.66 ms
5c1e987+dirty 1208.43 ms 1220.72 ms 12.29 ms
5125c43+dirty 3827.94 ms 1208.79 ms -2619.15 ms
5569641+dirty 3824.35 ms 1210.78 ms -2613.57 ms

App size

Revision Plain With Sentry Diff
0b5120f+dirty 5.15 MiB 6.68 MiB 1.53 MiB
4e0ba9c+dirty 5.15 MiB 6.67 MiB 1.51 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
bc0d8cf+dirty 5.15 MiB 6.67 MiB 1.51 MiB
c151573+dirty 5.15 MiB 6.68 MiB 1.53 MiB
7d6fd3a+dirty 3.38 MiB 4.77 MiB 1.39 MiB
a3265b6+dirty 5.15 MiB 6.68 MiB 1.53 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
5125c43+dirty 5.15 MiB 6.68 MiB 1.53 MiB
5569641+dirty 5.15 MiB 6.67 MiB 1.51 MiB

@github-actions
Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 504.47 ms 528.40 ms 23.93 ms
Size 48.30 MiB 53.58 MiB 5.28 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4953e94+dirty 398.80 ms 431.81 ms 33.01 ms
5569641+dirty 465.92 ms 532.22 ms 66.30 ms
100ce80+dirty 463.28 ms 532.10 ms 68.82 ms
ef27341+dirty 519.02 ms 553.42 ms 34.40 ms
8929511+dirty 469.49 ms 502.65 ms 33.16 ms
853723c+dirty 415.82 ms 460.94 ms 45.12 ms
3b6e9f9+dirty 442.39 ms 486.44 ms 44.05 ms
44c8b3f+dirty 492.13 ms 563.47 ms 71.34 ms
d038a14+dirty 405.08 ms 444.36 ms 39.28 ms
c151573+dirty 485.39 ms 495.18 ms 9.79 ms

App size

Revision Plain With Sentry Diff
4953e94+dirty 43.94 MiB 48.94 MiB 5.00 MiB
5569641+dirty 48.30 MiB 53.48 MiB 5.18 MiB
100ce80+dirty 48.30 MiB 53.46 MiB 5.15 MiB
ef27341+dirty 48.30 MiB 53.54 MiB 5.24 MiB
8929511+dirty 43.94 MiB 49.02 MiB 5.08 MiB
853723c+dirty 48.30 MiB 53.58 MiB 5.28 MiB
3b6e9f9+dirty 48.30 MiB 53.54 MiB 5.23 MiB
44c8b3f+dirty 48.30 MiB 53.46 MiB 5.15 MiB
d038a14+dirty 48.30 MiB 53.49 MiB 5.19 MiB
c151573+dirty 48.30 MiB 53.54 MiB 5.24 MiB

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.

fix(tracing): Enable fetch instrumentation when Expo SDK 56 expo/fetch is active

1 participant