fix(core): normalize autoSelectFamily timeout AggregateError#5329
Open
youcefzemmar wants to merge 1 commit into
Open
fix(core): normalize autoSelectFamily timeout AggregateError#5329youcefzemmar wants to merge 1 commit into
youcefzemmar wants to merge 1 commit into
Conversation
When `autoSelectFamily` exhausts all attempts with timeouts, `net.connect` raises an `AggregateError` whose surfacing previously depended on whether Node's family-attempt timer or undici's `connectTimeout` won the race. Wrap the aggregate as a `ConnectTimeoutError` when any inner error is ETIMEDOUT (or the aggregate itself carries the code) so callers see the same error shape regardless of ordering. The original `AggregateError` is preserved on `.cause`. Fixes nodejs#5092.
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.
What
In
lib/core/connect.js, when the socket'serrorevent fires with anAggregateErrorfromnet.connect'sautoSelectFamilyexhaustion, wrap it as aConnectTimeoutErrorif any inner error (or the aggregate itself) carriescode: 'ETIMEDOUT'. Message format matches the existingonConnectTimeoutoutput (attempted addresses + timeout). Original aggregate preserved on.cause.Why
The error reaching the dispatcher callback used to depend on which timer won the race:
connectTimeoutfired first →ConnectTimeoutErrorAggregateErrorThat ordering sensitivity is what #5092 reports. Single-error paths (e.g. one
ECONNREFUSED) are untouched, so theconnect-errconnect.jsstrict-equality assertion still holds.Testing
npx borp -p "test/connect-timeout.js"— green (new test included)npx borp -p "test/connect-errconnect.js"— green (single-error path unchanged)npx borp -p "test/node-test/autoselectfamily.js"— greeneslintclean on changed filestest/connect-pre-shared-session.jsfails withERR_SSL_EE_KEY_TOO_SMALLonmaintoo — pre-existing environment issue unrelated to this change.Notes
Some callers may rely on receiving the raw
AggregateError. The original is still accessible viaerror.cause, and the docs note this. Non-timeout aggregates (e.g. allECONNREFUSED) are left untouched.Fixes #5092.