Vite dev proxy can reuse an expired worker socket after an event-loop stall (ECONNRESET)
Maintainers usually reply within 2 days
@jkugsiya is already working on this.
Since Oct 7, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- nodejs, typescript, vite
- Domain
- backend-api-design, devtools
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- TypeScript
- Stars
- 11.5k
- Forks
- 968
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 64
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nitrojs/nitro
-
pending triage
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 2 days
-
cloudflare: `nitro deploy` fails when a parent directory has a Wrangler configPossibly taken @draarivpatel-ui claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
pending triage
Difficulty 5/5 Over a week Newbie friendliness 30/100
nitrojs/nitro#5205 · 1 reaction ·
Maintainers usually reply within 2 days
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ranxianglei/billion-context#8319 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
JimLiu/open-artifact#126 ·
-
bug repro-ready
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
mksglu/context-mode#1454 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
laststance/design-world#98 ·
Maintainers usually reply within 1 day
-
Add: KCM True crimeOpenapproved check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day