[BUG] `timeouts.idle` is cleared after completed keep-alive responses
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, node.js
Direzione di ricerca
Start with normalizeOptions(), Agent, and connect(), then trace how completed responses return sockets to Node's free socket pool. Verify the keep-alive path preserves the configured timeouts.idle value without replacing the existing connect() timeout behavior. Done means a completed keep-alive socket expires after the configured idle timeout, as described by the reproduction shape; PR #170 is referenced in the issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Summary
@npmcli/agent applies timeouts.idle while a socket is created, but completed keep-alive sockets can lose that timeout when Node moves them into the free socket pool. As a result, timeouts.idle protects in-flight idle requests, but it does not reliably expire pooled sockets after a response has completed.
Impact
Consumers that configure timeouts.idle expecting it to bound the lifetime of idle keep-alive sockets can keep completed sockets open indefinitely, or until the remote peer/server closes them. This is especially visible when a caller sets timeouts.idle below an upstream keep-alive timeout to avoid reusing sockets that the upstream might close first.
Current behavior
normalizeOptions()convertstimeoutinto the customtimeouts.idlevalue and removes the nativetimeoutoption.Agentstores the custom timeout separately and passes the remaining normalized options to the underlying Node/agent-base agent.connect()appliestimeouts.idledirectly to the socket when it is created.- After the response completes, Node keeps the socket alive and reapplies
agent.options.timeoutfor the free socket pool. - Since
agent.options.timeoutis absent, Node's free-socket timeout becomes0, clearing the idle timeout.
Expected behavior
If timeouts.idle is configured, completed keep-alive sockets should continue to expire after that idle timeout while they are in the free socket pool.
Reproduction shape
- Create an agent with
timeouts: { idle: 500 }andmaxSockets: 1. - Make a request to an HTTP server that responds successfully and keeps the connection alive.
- Consume the response body so the socket returns to the free socket pool.
- Wait longer than
timeouts.idlewhile the server's keep-alive timeout remains longer than the agent timeout.
Before the fix, the free socket remains open because Node resets its timeout to 0. After the fix, the free socket is destroyed after the configured idle timeout.
Proposed fix
Override the agent's free-socket keep-alive handling and reapply timeouts.idle after Node decides to keep a socket alive. This preserves the existing custom timeout behavior for active sockets and avoids changing native agent.options.timeout for active proxied requests.
Notes
This should not replace the custom timeouts.idle handling in connect(): that path still provides the package-specific IdleTimeoutError behavior for sockets that go idle before a response completes. The additional keep-alive handling is needed specifically for completed response sockets managed by Node's free socket pool.
See PR: #170
- Lingua principale
- JavaScript
- Stelle
- 9
- Fork
- 15
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun 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 npm/agent
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 48/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 22/100
-
[BUG] Agent does not respect npm's noproxy config when initiating request using environment insteadForse già presa @ychampion l’ha presa 17 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
-
Add LICENSE.mdForse già presa @Suryaseenivasan2005 l’ha presa 149 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
Issue simili
-
docs: add SECURITY.md vulnerability reporting policyForse già presa @AK-Lmn l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
flisk-sh/linux2wasm#12 ·
I maintainer di solito rispondono entro 1 giorno
-
possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Mintplex-Labs/anything-llm#7388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 60/100
I maintainer di solito rispondono entro 1 giorno
-
v6: Minified bootstrap.min.css is missing header infoForse già presa @lazerg l’ha presa oggi. Apertabug build confirmed has-pr v6
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
[workshop-sync] workshop/side-quest-26-01-forecast-costs.md: forecast default history window is inaccurateForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadocumentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
githubnext/gh-aw-workshop#6332 ·
I maintainer di solito rispondono entro 1 giorno