Cancel connection attempts after queued requests abort - #5662
Closed
dills122 wants to merge 3 commits into
Closed
Conversation
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
Fixes #386 by rejecting requests that abort while connection establishment is still pending and cancelling connection attempts once no queued request needs them.
Previously, abort handling was attached when a request reached
onRequestStart. A request waiting behind an unresolved connector had not reached that point, so aborting its signal did not settle the request until the connector eventually succeeded or failed.What Changed
request,stream,pipeline,connect, andupgradeconsistently.AbortSignaland abort it after every request depending on that attempt has been removed.connectionErrorand causing pools to evict an otherwise usable client.signal.Validation
npm run lintnpm run test:typescripttest/*.jsunit corpustest/node-test/**/*.jscorpustest/interceptors/*.jscorpusScope Notes
Custom connectors receive the attempt-scoped signal and should stop pending work when it aborts. A connector that ignores the signal cannot have its internal work forcibly stopped, but Undici still settles the request promptly and prevents a late socket or error from affecting a newer attempt.
The cancellation signal represents the lifetime of a connection attempt, not any single request. A shared attempt is cancelled only when all queued requests relying on it are gone.