net: Happy Eyeballs cancels every candidate when TCP RTT exceeds the 250ms attempt timeout — fetch fails with an empty-message ETIMEDOUT against healthy hosts
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- javascript, node.js
- Domaine
- backend, networking
Piste de recherche
Start by tracing Node's network family autoselection path and how --network-family-autoselection-attempt-timeout is applied to candidate connections; the issue does not name source files or tests. Reproduce with the supplied script and compare default behavior with --no-network-family-autoselection and a longer attempt timeout. Done means a healthy connection succeeds when its RTT exceeds the default attempt timeout, with regression coverage for the timeout behavior and useful error reporting.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
With Happy Eyeballs on (the default since v20), fetch() / https.get() fails outright against any destination whose TCP connect RTT exceeds the attempt timeout, because the same value is used both as the stagger interval between candidates and as the deadline that cancels each candidate. If RTT > attemptTimeout, every candidate is cancelled before its own SYN/ACK can arrive — including the last one — so the algorithm cannot succeed at all, while connecting without Happy Eyeballs succeeds on the first address.
Measured on v24.22.1 / darwin-arm64 against public hosts. curl and /usr/bin/python3 (SecureTransport) on the same machine at the same second succeed every time; Node is the only client that fails.
Reproduction (no accounts, no setup)
// repro.mjs
import net from 'node:net';
import dns from 'node:dns/promises';
const host = process.argv[2] ?? 'docker.io';
const { address } = await dns.lookup(host, { verbatim: true });
const t0 = Date.now();
const s = net.connect({ host: address, port: 443, family: 4 }); // Happy Eyeballs bypassed: explicit IP
s.on('connect', () => {
console.log(`tcp connect to one IP directly : OK in ${Date.now() - t0} ms`);
s.destroy();
const t1 = Date.now();
fetch(`https://${host}/`)
.then((r) => console.log(`fetch(https://${host}/) : ${r.status} in ${Date.now() - t1} ms`))
.catch((e) => console.log(`fetch(https://${host}/) : FAILED ${e.message}`
+ ` | cause=${e.cause?.code} message="${e.cause?.message}"`
+ ` | cause.errors=${e.cause?.errors?.length}`
+ ` (${e.cause?.errors?.[0]?.code} ${e.cause?.errors?.[0]?.address}) in ${Date.now() - t1} ms`));
});
$ node repro.mjs docker.io
tcp connect to one IP directly : OK in 384 ms
fetch(https://docker.io/) : FAILED fetch failed | cause=ETIMEDOUT message="" | cause.errors=6 | ETIMEDOUT 2600:9000:...:443 in 2798 ms
$ node --no-network-family-autoselection repro.mjs docker.io
tcp connect to one IP directly : OK in 386 ms
fetch(https://docker.io/) : 302 in 1255 ms
The failure is not a property of the destination. Run the same command twice a minute apart and the outcome tracks the current RTT across the 250 ms line:
| target | measured TCP RTT | fetch() at default budget |
|---|---|---|
docker.io |
384, 386 ms | FAIL, FAIL (2/2) |
docker.io |
255, 263 ms | 302, 302 |
quay.io |
369, 388 ms | FAIL, FAIL (2/2) |
quay.io |
237, 265 ms | 200, 200 |
arxiv.org (A-only edge, 4 ms) |
4 ms | 200 (never affected) |
Budget sweep, one variable
Same host, same minute, only --network-family-autoselection-attempt-timeout changes (RTT sampled in the same run):
| budget | RTT sample | result |
|---|---|---|
| 250 (default) | 465 ms | FAIL |
| 250 (default) | 365 ms | FAIL |
| 300 | 368 ms | FAIL |
| 350 | 457 ms | 200 in 2970 ms |
| 350 | 349 ms | FAIL |
| 400 | 372 ms | 200 in 2178 ms |
| 500 | 383, 362 ms | 200, 200 |
| 600 | 389 ms | 200 |
The knee sits exactly at the measured RTT. Note the successful marginal runs take ~2.1–3.0 s — i.e. the winner is the 6th–9th candidate, which is what you get when candidates are launched one attemptTimeout apart and only the last ones are still alive when RTT ≈ budget.
The reported error actively misleads
https.get() rejects with the AggregateError itself (no cause); fetch() wraps it in TypeError: fetch failed:
{ "ctor": "AggregateError", "name": "AggregateError", "message": "", "code": "ETIMEDOUT",
"hasCause": false, "nErrors": 18 }
tally: {"ETIMEDOUT@v4": 9, "EHOSTUNREACH@v6": 9}
sample: {"message": "connect ETIMEDOUT 221.194.164.123:443", "code": "ETIMEDOUT",
"address": "221.194.164.123", "port": 443, "syscall": "connect"}
keys: ["errno","code","syscall","address","port"]
Three problems for anyone debugging this in production:
err.messageis the empty string at the top level — log lines that printerr.messageprint nothing.- Every v4 sub-error says
connect ETIMEDOUT <ip>:443, yet a plainnet.connectto that exact IP completes in ~370 ms. The addresses were never given a chance to finish; they were cancelled at 250 ms. Reporting them asETIMEDOUTsends people hunting for a firewall/blackhole that isn't there (I did — see below). - Nothing in the error mentions the attempt timeout, the number of candidates tried, or that
--no-network-family-autoselectionwould have worked.ECONNREFUSED/EHOSTUNREACHper candidate is fine, but "we cancelled all of them because the budget expired" is a distinct, actionable cause.
What I ruled out first (so you don't have to)
On the same machine, same second: curl 8.7.1 200 · system python3 urllib 200 · openssl s_client handshake OK · Node against pypi/npm/github/google/eastmoney all 200 · 9 v4 addresses in parallel 9/9 OK · tls.connect to each IP individually + hand-written HTTP request 10/10 200 OK. net.setDefaultAutoSelectFamily(false) fixes it. So it is not the network, the certificate, TLS version, ALPN, UA, rate limiting, or the post-quantum ClientHello.
Expected behaviour
Fall back to a working address instead of failing the whole attempt. Options that would each fix my case, in rough order of preference:
- Once all candidates have been cancelled without a completed handshake, retry at least one round without the per-candidate cancellation (curl/SecureTransport effectively do this and never fail here). Or: treat
attemptTimeoutonly as the stagger delay, and let an in-flight candidate live until the socket-level timeout. - Raise the default. RFC 8305's 250 ms default assumes intra-domain reachability; the public internet from many networks is routinely 250–500 ms, which makes the default configuration strictly worse than disabling Happy Eyeballs.
- Make the failure self-describing: non-empty message, and a cause that says "all N candidates exceeded the X ms attempt timeout (last RTT-class: v4/v6)".
Environment / workarounds in use
Node v24.22.1, darwin-arm64, macOS 15, no IPv6 egress on the host. We unblocked production with NODE_OPTIONS=--network-family-autoselection-attempt-timeout=1000 (verified: 8/8 previously-failing call sites now 200, and RTT to unrelated hosts unchanged at 32–192 ms, so the raised budget costs nothing when addresses are healthy). --no-network-family-autoselection also works but gives up fast-fail for genuinely dual-stacked hosts.
Related
- #59738 — "TCP connection timeout in https appears to be just 300ms, causing dropped connections for distant servers" — same symptom, closed as NOT_PLANNED/stale; its reporter also saw it on distant servers only. Worth reopening given it makes the default config fail on healthy destinations.
- #54359 — "Happy eyeballs implementation times out prematurely" (closed COMPLETED)
- #48145 — "Implement parallel Happy Eyeballs as described in RFC 8305" (open) — if #48145 lands with RFC-correct connection timeout semantics (a timer per candidate, independent of the resolution/head-request delays), it likely subsumes this.
- Langage dominant
- JavaScript
- Étoiles
- 124k
- Forks
- 38k
- Merge moyen
- 4 j 2 h
- PR mergées (30 j)
- 266
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de nodejs/node
-
Difficulté 2/5 1-3 heures Accessibilité débutants 69/100
Les mainteneurs répondent en général sous 1 jour
-
fs: document readStream.start and readStream.endPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertedoc
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
nodejs/node#67848 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
doc: document the Buffer.prototype.*Slice() methodsPeut-être pris @AyushCipher l’a pris aujourd’hui. Ouvertedoc
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
nodejs/node#67847 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
`styleText` fast path bypasses `options` and `options.validateStream` validationPeut-être pris @GBra-4-669 l’a pris il y a 8 jours. Ouverteutil
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
riscv64
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
nodejs/node#67655 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de nodejs/node
Issues similaires
-
bug triage needed
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
[Resource]: PersephoneOuverteresource-submission validation-passed
Difficulté 1/5 Moins d'une heure Accessibilité débutants 82/100
hesreallyhim/awesome-claude-code#3773 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
tabatkins/railroad-diagrams#129 ·
-
web: api() turns a null or object-valued error body into a TypeError or "[object Object]" and loses the statusPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour