Repository navigation
Conversation
Visual regressionNo visual differences at |
huntie
marked this pull request as ready for review
November 23, 2026 16:23
Collaborator
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:
| #include <react/networking/NetworkReporter.h> | ||
|
|
||
| #include <cstddef> | ||
| #include <mutex> |
Collaborator
There was a problem hiding this comment.
Nit: should this go inside the REACT_NATIVE_DEBUGGER_ENABLED block with <unordered_map>?
This branch has not been deployed
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.cppfor arm64-v8a with the NDK andREACT_NATIVE_DEBUGGER_ENABLED. Not run on a device.