net: Happy Eyeballs cancels every candidate when TCP RTT exceeds the 250ms attempt timeout — fetch fails with an empty-message ETIMEDOUT against healthy hosts
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
- Área
- backend, networking
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- JavaScript
- Estrellas
- 124k
- Forks
- 38k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 266
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nodejs/node
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día
-
fs: document readStream.start and readStream.endPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertodoc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
nodejs/node#67848 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
doc: document the Buffer.prototype.*Slice() methodsPosiblemente ocupada @AyushCipher la tomó hoy. Abiertodoc
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
nodejs/node#67847 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
`styleText` fast path bypasses `options` and `options.validateStream` validationPosiblemente ocupada @GBra-4-669 la tomó hace 8 días. Abiertoutil
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
riscv64
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
nodejs/node#67655 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de nodejs/node
Issues similares
-
bug triage needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
[Resource]: PersephoneAbiertoresource-submission validation-passed
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
hesreallyhim/awesome-claude-code#3773 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 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 statusPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
OCM: shares using the `embedded` protocol are rejected with "Missing sharedSecret in protocol"Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día