fix(core): normalize autoSelectFamily timeout AggregateError by youcefzemmar · Pull Request #5329 · nodejs/undici (original) (raw)

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.

@youcefzemmar marked this pull request as ready for review

May 27, 2026 14:12

mcollina

metcoder95

ronag added a commit to nxtedition/undici that referenced this pull request

Jun 6, 2026

@ronag @claude

When autoSelectFamily is enabled and every attempted address fails with ETIMEDOUT, Node emits an AggregateError on the socket 'error' event, which was forwarded raw to the caller. Wrap it in a ConnectTimeoutError (preserving the original on .cause) so callers see a consistent error regardless of which timer wins the race. Downstreamed from nodejs#5329, with its test/connect-timeout.js regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

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

[ Show hidden characters]({{ revealButtonHref }})