fix: reject a buffered response when the request was aborted in flight - #231
Open
bengeorge wants to merge 1 commit into
Open
fix: reject a buffered response when the request was aborted in flight#231bengeorge wants to merge 1 commit into
bengeorge wants to merge 1 commit into
Conversation
|
@bengeorge is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
bengeorge
force-pushed
the
fix/abort-after-buffered-response
branch
from
September 8, 2026 06:19
c5b123e to
59008ce
Compare
bengeorge
force-pushed
the
fix/abort-after-buffered-response
branch
from
September 8, 2026 06:24
59008ce to
08a8d4b
Compare
2 tasks
bengeorge
marked this pull request as ready for review
September 8, 2026 12:05
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.
Closes #232.
Problem
fetch()can resolve as a normal success after itsAbortSignalhas fired. Cronet'sUrlRequest.cancel()andURLSessionTask.cancel()are best-effort and are documented no-ops once the request has completed, so when the cancel loses that racenitroFetchRawhands back a response the caller has already abandoned — which then goes on to parse a body it discarded.nitroStreamFetchalready checkssignal?.abortedin several places; only the buffered path is missing it.Full diagnosis and the device measurement are in #232. In short: on a Fire TV stick, 4 of 4 superseded search requests completed and were JSON-parsed with
signal.aborted === true; with this change, 0 of 4.Fix
Placed before
NetworkInspector._recordEndso an aborted request falls into the existingcatchand is recorded as aborted, rather than as a 200 the caller never received.The existing
abort mid-flight cancels a slow requestharness case passes without this change — aborting 100 ms into/delay/20lets the native cancel win comfortably — so it never covered the window where the response is already buffered. Added a case alongside it that blocks the JS thread to hold that window open.Testing
bun test— 10 pass, 2 existing todos, 0 failbun typecheck— cleaneslint "**/*.{js,ts,tsx}"— 0 errors, the 2 existingno-shadowwarnings in the Expo plugin files. Run under node;bun linthits an unrelatedstructuredClone is not definedin@eslint/config-arrayon macOS that CI on Linux does nottsc --noEmitinexample/— the new harness case adds no errors; the 4 in that file are identical to those onmaintest:harnessneeds the example app built onto a device, which I have not done