Skip to content

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

Closed

Description

@tareksabry1337

Versions

@sentry/react-native 8.30.0, Expo 57.0.26, expo-router 57.0.24, @expo/metro-runtime 57.0.16, React Native 0.86.3.

What happens

isExpoFetchEnabled() (utils/environment.js, added in #6225) returns false in an Expo Router app even though expo/fetch is the active global fetch. As a result the SDK keeps fetch tracing and fetch breadcrumbs off, and requests made with fetch get no http.client span, no breadcrumb and no trace headers from the JS side.

Cause: the check looks for Symbol.for('expo.builtin') on globalThis.fetch. In an Expo Router app, @expo/metro-runtime replaces global.fetch with a wrapper (wrapFetchWithWindowLocation in src/location/install.native.ts, to support relative URLs). The wrapper is a new function, so it doesn't carry the expo.builtin marker. It does carry its own marker, Symbol.for('expo.polyfillFetchWithWindowLocation').

Steps to reproduce

  1. Expo SDK 57 app using Expo Router, without EXPO_PUBLIC_USE_RN_FETCH.
  2. Call isExpoFetchEnabled() after startup, or check globalThis.fetch[Symbol.for('expo.builtin')]: it's undefined.
  3. Make a fetch request inside an active span: no http.client span or breadcrumb is created for it.

What we did

We worked around it in two steps: first we turned fetch tracing on manually (reactNativeTracingIntegration({ traceFetch: true })). Later we switched the app back to React Native's own fetch with EXPO_PUBLIC_USE_RN_FETCH=1, because the replay Network tab only records XHR requests, and in that mode the existing XHR instrumentation covers everything.

A fix could be for the detection to also recognise the metro-runtime wrapper, or for Expo to copy the expo.builtin marker onto its wrapper. Happy to file the second part with Expo if that's the better place.

Activity

  1. linear-code commented on Oct 12, 2026

    @linear-code
  2. antonis commented on Oct 12, 2026

    @antonis
    Contributor

    Thank you for reporting. We will investigate this and iterate back 🙇

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 12, 2026
  4. self-assigned this
    on Oct 12, 2026
  5. antonis commented on Oct 13, 2026

    @antonis
    Contributor

    Thanks for the detailed report and for tracking down the root cause, @tareksabry1337! 🙏

    You're right. @expo/metro-runtime replaces global.fetch with a wrapper that drops the expo.builtin marker, so isExpoFetchEnabled() returns false in Expo Router apps on SDK 56+. Fetch tracing and fetch breadcrumbs then stay off by default.

    On the workarounds:

    • Keep expo/fetch: traceFetch: true gives you spans and trace headers. Fetch breadcrumbs are controlled separately, so you'd also want Sentry.breadcrumbsIntegration({ fetch: true }). This doesn't create duplicates, because expo/fetch doesn't go through XHR.
    • EXPO_PUBLIC_USE_RN_FETCH=1: this is the more complete option today, since our XHR instrumentation then covers spans, breadcrumbs and the Replay Network tab. Make sure to remove any traceFetch: true or fetch: true overrides in this mode. React Native's fetch is built on XHR, so having both on would give you duplicate spans and breadcrumbs.

    Next steps on our side:

    • We'll look into making the detection also recognize the metro-runtime wrapper, without misdetecting setups where the wrapper sits on top of React Native's fetch (SDK ≤55, or the EXPO_PUBLIC_USE_RN_FETCH opt-out).
    • We'd welcome you filing the Expo-side change (copying the expo.builtin marker onto the wrapper) if you're still up for it. That's the cleanest long-term fix. Please link it here.
    • The Replay Network tab only recording XHR requests is a separate limitation. We'll track it separately.

    We'll update this issue as we make progress.

  6. cwoolum commented on Oct 14, 2026

    @cwoolum

    A few things the thread doesn't cover yet:

    • Expo SDK 56 and 57 pin @sentry/react-native ~7.11.0 (SDK 58 moves to ~8.28.0). 7.x has no expo/fetch detection, so apps on Expo's pinned version get no fetch spans or fetch breadcrumbs on iOS/Android, Router or not. A note on the automatic-instrumentation page would help.
    • For the detection work: the metro-runtime wrapper also hides whatwg-fetch's fetch.polyfill. Behind it, expo/fetch and RN's fetch look the same from JS, so EXPO_PUBLIC_USE_RN_FETCH is the only reliable signal until the wrapper keeps the marker.
    • With traceFetch: true: consider enableHTTPTimings: false. The per-span resource listener is removed only when a matching entry arrives, and expo/fetch doesn't appear to report any. Also, the span keeps the full URL, query included, in url/http.url, so scrubbing http.query alone doesn't remove it.

    @tareksabry1337 I opened the Expo side: expo/expo#51545. It copies the marker only when the wrapped fetch has it, so RN's fetch is never misdetected.

  7. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 14, 2026
  8. antonis commented on Oct 14, 2026

    @antonis
    Contributor

    Thank you for iterating on this @cwoolum and the expo PR 🙇

  9. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 14, 2026
  10. dub578 commented on Oct 17, 2026

    @dub578

    FYI enableHTTPTimings: false doesn't actually work here (8.28.0 through 8.31.0). reactNativeTracingIntegration declares it (default) but never passes it to instrumentOutgoingRequests (here), so the browser default of true wins and every traced fetch adds a resource handler that only gets removed when a timing entry shows up (here). expo/fetch never sends one, so they pile up. 10 fetches, 10 handlers, option set or not.

    Looks like setup just needs enableHTTPTimings: finalOptions.enableHTTPTimings.

  11. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Oct 17, 2026
  12. antonis commented on Oct 19, 2026

    @antonis
    Contributor

    Thank you @dub578 🙇

  13. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Oct 19, 2026
  14. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #6965, which was included in the 8.34.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions