Repository navigation
Conversation
Visual regressionNo visual differences at |
huntie
marked this pull request as ready for review
November 23, 2026 16:23
Member
Author
|
@huntie-bot Pick this and the next PR to 0.89 when merged; they are independent. |
robhogan
approved these changes
Nov 23, 2026
robhogan
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. One pre-existing gap while you're here (not blocking)? Android's reportRequestFailed never clears responseBuffers, unlike iOS, so a streamed text request that fails or is cancelled keeps its buffer for the life of the process. Should be a few lines under the new lock:
3 tasks
huntie
added a commit
to expo/expo
that referenced
this pull request
Nov 24, 2026
…53160) ## Summary **Context - 1P Network Reporting in Expo** Expo's CDP `Network` support predates React Native's first party support in 0.83, with an Expo CLI based stack that bypasses `RCTNetworking` and the modern CDP infra in core. This stack aims to migrate Expo to the upstream `InspectorNetworkReporter` stack, gaining tighter native functionality and allowing us to drop the Expo CLI relay. **This diff** Follow-up to #52866 from review. - Make `ExpoNetworkReporter` a singleton, `ExpoNetworkReporter.shared`, as `RCTInspectorNetworkReporter` is one. Each method takes the request id, and in-flight requests live in one dictionary behind one `Mutex`, the core backport rather than `NSLock`, so a call out of order or after the request has finished never reaches `RCTInspectorNetworkReporter`. - Store text bodies through the string branch of `maybeStoreResponseBody`, by way of a small Objective-C helper since the header types the argument as `NSData`, with a TODO for the text variant in react/react-native#60188. That path writes under the core reporter's lock, unlike `maybeStoreResponseBodyIncremental`, whose process-wide buffer `RCTNetworking` appends to on its own queue without one. - Store and end a finished request outside the lock, so decoding a body up to the 1 MB preview cap never blocks other requests. - Stop buffering once a response exceeds the 1 MB preview cap, instead of appending every later chunk that fits. - Rename the lifecycle methods to match `ExpoRequestInterceptorProtocolDelegate`: `willSendRequest`, `didReceiveResponse`, `didReceiveData`, `didFinishLoading` and `didFailLoading`. `reportResponseEnd` still reads and removes from that buffer without a lock in React Native; react/react-native#60187 adds the lock upstream. Linear: [ENG-28824](https://linear.app/expo/issue/ENG-28824/integrate-rn-networkreporter-stack-into-core-expo-modules-ios) (parent ENG-27596, SDK 59) ## Test Plan Built `bare-expo` at each layer of this stack, on an iPhone simulator (iOS 27.2) and an Android emulator (API 37), against React Native 0.89.0-rc.2, rebuilding the `expo` and `expo-image` JS at each layer. With `EXPO_UNSTABLE_CORE_NETWORK_INSPECTOR=1` and the Network domain enabled over CDP, `Runtime.evaluate` drove an `expo/fetch` request, `Image.loadAsync` and `Asset.downloadAsync`: | Layer | iOS | Android | |---|---|---| | #53160 (this) | ✅ Builds; nothing reported yet | — | | #52867 | ✅ fetch: text body, initiator stack | — | | #52868 | ✅ + image: base64 body | — | | #52870 | ✅ + image initiator stack | — | | #53028 | — | ✅ Builds; nothing reported yet | | #53029 | — | ✅ fetch: text body, initiator stack | | #53030 | — | ✅ + image: base64 body, initiator stack | | #53031 | ✅ + asset, no body | ✅ + asset: base64 body | | #53720, #53721 | ✅ unchanged | ✅ unchanged | At the top of the stack on iOS: - ✅ 30 concurrent `expo/fetch` requests all finish with their text bodies. - ✅ `Image.prefetch` is reported. - ✅ With `EXPO_UNSTABLE_CORE_NETWORK_INSPECTOR` unset, fetch, image, prefetch and asset requests each show once. ## Screenshots No UI change. ## Checklist <!-- Please check the appropriate items below if they apply to your diff. --> - [ ] I added a changeset and followed [this short guide](https://github.com/expo/expo/blob/main/CONTRIBUTING.md#-before-submitting) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
gabrieldonadel
pushed a commit
that referenced
this pull request
Nov 30, 2026
(cherry picked from commit 5afc5d3)
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.
Summary
RCTInspectorNetworkReporter(iOS) andJInspectorNetworkReporter(Android) buffer incremental text response bodies in a global map with no lock:NetworkingModulereads response bodies on OkHttp's dispatcher threads, so two concurrent requests can insert into thestd::unordered_mapat once, and a rehash during another request'sreportResponseEndlookup is undefined behavior.RCTNetworkingonly reaches theNSMutableDictionaryfrom one serial queue, but the class is public, and a second reporter callingreportResponseEndfrom another queue, as Expo's does from itsURLSessiondelegate, mutates the dictionary whileRCTNetworkingappends to it.Changes
responseBuffersaccess with onestd::mutexon each platform.storeResponseBodyafter releasing the lock, so it never nests withNetworkReporter's own locks.REACT_NATIVE_DEBUGGER_ENABLED, so release builds are unchanged.Changelog:
[General][Fixed] - React Native DevTools: Fix a data race when concurrent requests buffer response bodies
Test Plan
iOS: Built an Expo app on React Native 0.89.0-rc.0, whose copy of this file is identical to
main, from source with Thread Sanitizer, on an iPhone simulator (iOS 27.2). A local server streamed 40 chunked text lines per response; each round sent 60 XHR text requests throughRCTNetworkingand 60expo/fetchrequests at once, with the Network domain enabled over CDP.maybeStoreResponseBodyIncrementalandRCTNetworking'sreportResponseEndran oncom.meta.react.turbomodulemanager.queue, while Expo'sreportResponseEndran oncom.apple.NSURLSession-delegate, so the race is reachable.Network.getResponseBodyreturned all 40 lines for 300 of 300 XHR and 300 of 300expo/fetchrequests.Android: ✅ Compiled
JInspectorNetworkReporter.cppwith the NDK, with and withoutREACT_NATIVE_DEBUGGER_ENABLED. Not run on a device.