Skip to content

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

@antonis

Description

@antonis

Description

Expo SDK 56 replaces globalThis.fetch with a native implementation (expo/fetch) that bypasses XMLHttpRequest entirely. The Sentry React Native SDK disables fetch tracing on native (traceFetch: false) because RN's default fetch is a whatwg-fetch polyfill over XHR — tracing both would cause duplicates. However, with expo/fetch active, XHR instrumentation no longer captures network requests, resulting in:

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

Root Cause

  • reactNativeTracingIntegration defaults to traceFetch: false and traceXHR: true on native
  • breadcrumbsIntegration defaults to fetch: false on native
  • expo/fetch is a fully native Expo Module (ExpoFetchModule) that does not use XHR
  • XHR instrumentation never fires for expo/fetch requests

Affected Versions

  • Expo SDK 56+ (where expo/fetch is the default)
  • All versions of @sentry/react-native

Workaround

Users can manually enable fetch tracing and breadcrumbs:

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

Alternatively, opt out of expo/fetch by setting EXPO_PUBLIC_USE_RN_FETCH=1 in the .env file.

Proposed Fix

Detect expo/fetch at runtime via the Symbol.for('expo.builtin') marker that Expo's installGlobal sets on replaced globals, and flip traceFetch and fetch breadcrumbs to true when detected.

References

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions