Repository navigation
Fix XMLHttpRequest cancellation before native request creation - #59806
Open
shoutoutuoadi325 wants to merge 1 commit into
Open
shoutoutuoadi325 wants to merge 1 commit into
shoutoutuoadi325 wants to merge 1 commit into
Conversation
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:
An iOS upload can be aborted while native networking is still constructing its body, before its request ID is returned. The delayed creation callback then attaches the cancelled request to the XHR. If the XHR has been reused for a retry, this can replace the new request's ID, deliver the old response, or leave the new request unfinished.
Capture the request generation in send() and invalidate it in reset(). A creation callback from an obsolete generation cancels its native request and returns before changing the XHR or reporting it to the interceptor. Add regression coverage for both callback orders, abort before creation, stale response isolation, and normal cancellation after creation.
Fixes #59805.
Changelog:
[IOS][FIXED] - Cancel XMLHttpRequest requests created after abort without overwriting a reused request's identifier.
Test Plan:
Network and Blob Jest suites: 5 suites / 59 tests passed.
XHR suite: 18 tests passed. Three new race cases fail on unpatched main and when the latest stable v0.88.1 XHR source is substituted into the same Jest harness.
The four new cases also pass with haste.defaultPlatform set to android. A full Android resolution override has two pre-existing failures (custom performance logger and sorted response headers); both were confirmed with the original source and original tests. The repository's default iOS resolution suite passes completely.
Static checks passed:
RNTester Playground and server provide a native reproducer with a delayed URI upload body. The server endpoints and Playground Babel transformation were verified locally. An iOS simulator build was not run because CocoaPods is unavailable in this environment.