fix(tracing): Enable fetch instrumentation when expo/fetch is active#6226
Draft
antonis wants to merge 3 commits into
Draft
fix(tracing): Enable fetch instrumentation when expo/fetch is active#6226antonis wants to merge 3 commits into
antonis wants to merge 3 commits into
Conversation
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>
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
|
@sentry review |
There was a problem hiding this comment.
✅ 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>
Contributor
iOS (legacy) Performance metrics 🚀
|
| 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 |
📲 Install BuildsAndroid
|
Contributor
iOS (new) Performance metrics 🚀
|
| 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 |
Contributor
Android (new) Performance metrics 🚀
|
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📢 Type of change
📜 Description
Expo SDK 56 replaces
globalThis.fetchwith a native implementation (expo/fetch) that bypassesXMLHttpRequestentirely. The SDK disabled fetch tracing on native (traceFetch: false) because RN's default fetch is awhatwg-fetchpolyfill over XHR — enabling both would cause duplicate spans. However, withexpo/fetchactive, XHR instrumentation never fires for network requests, resulting in:http.clientspanssentry-trace/baggageheaders injected (broken distributed tracing)Changes
environment.ts— AddedisExpoFetchEnabled()detection function that checks forSymbol.for('expo.builtin')onglobalThis.fetch, which Expo'sinstallGlobalsets on all replaced globals.reactnativetracing.ts—traceFetchnow defaults totruewhenexpo/fetchis 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 totruewhenexpo/fetchis detected. Updated JSDoc for bothfetchandxhroptions to reflect the new behavior.Behavior matrix
traceFetchtraceXHRfetchbreadcrumbsfalsetruefalsefalsetruefalsetruetruetrueEXPO_PUBLIC_USE_RN_FETCH=1falsetruefalsetruetruetrue💡 Motivation and Context
Fixes #6225
Part of #6212
Workaround (for users before this fix ships)
Or opt out of expo/fetch:
EXPO_PUBLIC_USE_RN_FETCH=1in.env.💚 How did you test it?
isExpoFetchEnabled()— 4 cases (undefined fetch, plain fetch, expo/fetch with symbol, symbol present but false)traceFetchdefault — 4 cases (mobile without expo/fetch, mobile with expo/fetch, web, user explicit override)fetch: falseoverride)📝 Checklist
sendDefaultPIIis enabled🔮 Next steps