Vite dev proxy can reuse an expired worker socket after an event-loop stall (ECONNRESET)
I maintainer di solito rispondono entro 2 giorni
@jkugsiya ci sta già lavorando.
Dal 7/10/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- nodejs, typescript, vite
- Ambito
- backend-api-design, devtools
Direzione di ricerca
Start by running the linked reproduction with pnpm repro, then trace Nitro's development fetch through env-runner's BaseEnvRunner.fetch to httpxy's proxyFetch. Compare the failing run with control:idle and control:fresh, and use the shown shared-agent call as the boundary to investigate. Done means the blocked-parent scenario no longer fails while the existing controls and mutation-safety concern remain respected.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment
- Nitro:
3.0.260903-beta(registrylatestchecked on 2026-10-01) - Vite:
8.3.1 - env-runner:
0.2.3 - httpxy:
0.5.5 - srvx:
1.0.5 - Node.js:
26.8.1 - pnpm:
12.4.2 - OS: Linux x86_64
- Integration:
nitro/vite, default Node worker runner
The reproduction is a standalone Nitro 3 + Vite project with one route returning new Response('ok'). It does not use Nuxt, TanStack Start, a database, or application lifecycle hooks.
Reproduction
https://github.com/grantsiemens/nitro-dev-proxy-repro
git clone https://github.com/grantsiemens/nitro-dev-proxy-repro.git
cd nitro-dev-proxy-repro
pnpm install --frozen-lockfile
pnpm repro
The project follows the suggested starter's one-route structure, adapted to Nitro 3's Vite plugin because the linked starter branch currently uses Nitro 2.
Please run it under native Node; the reported results were not verified in StackBlitz/WebContainers or CodeSandbox.
The script:
- Starts Vite with the real Nitro plugin and captures its Nitro instance through the module API.
- Calls
nitro.fetchand consumes the successful response body. - Pauses only the parent thread for 6.5 seconds using
Atomics.wait. The stock worker keeps running and its unchanged HTTP server expires the idle connection. - Calls
nitro.fetchagain immediately after the pause.
The second request fails with ECONNRESET. Read-only HTTP diagnostics record reusedSocket: true on the failed request. The script exits with code 1 after closing Vite and Nitro.
Controls included in the same project:
pnpm control:idle
pnpm control:fresh
control:idlereplaces the blocking pause with an asynchronous delay of the same duration. Both requests succeed; exit code 0.control:freshretains the blocking pause and passes{ agent: false }from env-runner to httpxy. Both requests succeed; exit code 0. This optional control applies the one-line change in memory; it does not modify installed files.
The default failing reproduction uses unmodified upstream packages. It does not destroy sockets, shorten server timeouts, replace the worker implementation, or restart workers between requests. The repository includes the lockfile and captured output for all three scenarios.
Describe the bug
Nitro's Vite development transport can reuse a pooled HTTP connection whose worker-side socket has expired while the parent event loop was blocked. The next otherwise valid request rejects with ECONNRESET rather than reaching the route.
The call path is Nitro's development fetch → env-runner BaseEnvRunner.fetch → httpxy proxyFetch, which uses a shared keep-alive agent by default.
This appears to be the general reused-socket race documented by Node:
https://nodejs.org/api/http.html#requestreusedsocket
Could this be handled or mitigated at the development transport boundary, or is there a supported configuration for avoiding worker-connection reuse? I am happy for this report to be transferred to env-runner/httpxy if that is the better owner.
Additional context
We investigated this after intermittent ECONNRESET failures in a larger application's development server. The isolated reproduction demonstrates the same transport failure without that application's code, but it does not establish that the original incidents involved this exact event-loop stall. Ordinary requests and asynchronous idle periods succeeded in the isolated checks.
Our current development-only workaround changes:
return proxyFetch(this._address, this._resolveFetchInput(input), init);
to:
return proxyFetch(this._address, this._resolveFetchInput(input), init, { agent: false });
This avoids connection reuse at the cost of a fresh local connection per request. It does not retry requests or suppress upstream errors. I am reporting it as a verified workaround, not assuming it is the preferred upstream fix; blindly retrying requests would be inappropriate for mutations.
Logs
Unmodified upstream transport (`pnpm repro`, exit 1):
Node v26.8.1; freshConnections=false; asyncIdle=false
First request: 200 ok
Pausing parent for 6500 ms; worker retains default idle timeout
{"code":"ECONNRESET","reusedSocket":true}
Request failed: ECONNRESET: socket hang up
Fresh-connection control (`pnpm control:fresh`, exit 0):
Node v26.8.1; freshConnections=true; asyncIdle=false
First request: 200 ok
Pausing parent for 6500 ms; worker retains default idle timeout
Second request: 200 ok
Asynchronous-idle control (`pnpm control:idle`, exit 0):
Node v26.8.1; freshConnections=false; asyncIdle=true
First request: 200 ok
Pausing parent for 6500 ms; worker retains default idle timeout
Second request: 200 ok
- Lingua principale
- TypeScript
- Stelle
- 11.5k
- Fork
- 968
- Merge medio
- 4g 9h
- PR unite (30g)
- 64
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nitrojs/nitro
-
pending triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
I maintainer di solito rispondono entro 2 giorni
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configForse già presa @draarivpatel-ui l’ha presa 13 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 2 giorni
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
pending triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
nitrojs/nitro#5205 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di nitrojs/nitro
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
amosblomqvist/learnharness#1141 ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ranxianglei/billion-context#8319 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
tencent-connect/dsh-qqbot#148 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
JimLiu/open-artifact#126 ·
-
redis.expireTime() returns relative TTL seconds on live host instead of Unix timestamp secondsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100