fix(interceptor/dump): reject aborted requests when response is smaller than maxSize - #5685
Merged
metcoder95 merged 1 commit intoAug 13, 2026
Conversation
…er than maxSize Signed-off-by: codeAnqiang-ma <273298913+codeAnqiang-ma@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5685 +/- ##
==========================================
- Coverage 93.43% 93.34% -0.09%
==========================================
Files 110 110
Lines 38733 38776 +43
==========================================
+ Hits 36190 36196 +6
- Misses 2543 2580 +37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Aug 13, 2026
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.
This relates to...
Fixes #5684
Rationale
DumpHandler.onRequestStartreplacescontroller.abortwith its own method (lib/interceptor/dump.js:31), which only sets the handler-localthis.aborted. The underlyingRequestController's#abortedfield is only set inside its originalabort()method (lib/core/request.js:76-86), which is shadowed by the hijack — socontroller.abortedcan never becometrueafterwards.onResponseStart(line 48) andonResponseData(line 72) correctly check the handler-localthis.aborted, butonResponseEnd(line 87) checkedthis.#controller.aborted, a condition that is alwaysfalse.Consequence: for an aborted request whose response body is smaller than
maxSize,onResponseStartis swallowed andonResponseEndforwards a normal end to a downstream handler that never sawonResponseStart. Therequest()promise never settles — it hangs forever. With a body larger thanmaxSize, the same abort correctly rejects withAbortErrorvia the check inonResponseData, so the outcome of an abort currently depends on the response body size.The existing test "Should dump on already aborted request" asserts the expected semantics (aborted request →
AbortError), but only exercises thebody > maxSizepath.Changes
lib/interceptor/dump.js: inonResponseEnd, check the handler-localthis.aborted(consistent withonResponseStartandonResponseData) instead of the never-truethis.#controller.aborted.test/interceptors/dump-interceptor.js: add a regression test mirroring "Should dump on already aborted request" with a response body (256 B) smaller thanmaxSize(512 B). Without the fix the test times out (the promise never settles); with the fix it rejects withAbortError.Features
N/A
Bug Fixes
interceptors.dump()now reject withAbortErrorregardless of response body size, instead of hanging forever when the body is smaller thanmaxSize.Breaking Changes and Deprecations
N/A
Test evidence
Regression test without the fix (lib change stashed):
With the fix:
Full
test/interceptors/suite with the fix: all 14 files pass (cache 87/87, decompress 27/27, deduplicate 34/34, dns 30 pass + 3 skip, dump 12/12, redirect 83/83, retry 16/16, response-error 6/6, ...).npm run lintpasses.Note: #4634 restructures the dump handler lifecycle but keeps the
this.#controller.abortedcheck inonResponseEnd, so it does not address this hang. This one-line fix is independent and can land regardless.This fix was prepared with AI assistance; I reproduced the bug locally and reviewed every change.
Status