Bug description
A long-lived Socks5ProxyAgent retains an empty per-origin Pool after either a SOCKS connection failure or a normal target disconnect. The internal pool map therefore grows with distinct destinations until the agent itself is closed.
Expected behavior
Once a per-origin pool has no connected clients and is not busy, it should be removed from the agent cache.
Actual behavior
Pools remain strongly referenced by the agent map after connectionError and disconnect.
Reproduction
The accompanying regression coverage creates a request through a local SOCKS5 test server, waits for a normal target disconnect, and verifies that the per-origin pool cache is empty. It also verifies the failed-connection path.
Environment
- undici: 8.9.0
- Node.js: 26.4.0
- macOS
Bug description
A long-lived
Socks5ProxyAgentretains an empty per-originPoolafter either a SOCKS connection failure or a normal target disconnect. The internal pool map therefore grows with distinct destinations until the agent itself is closed.Expected behavior
Once a per-origin pool has no connected clients and is not busy, it should be removed from the agent cache.
Actual behavior
Pools remain strongly referenced by the agent map after
connectionErroranddisconnect.Reproduction
The accompanying regression coverage creates a request through a local SOCKS5 test server, waits for a normal target disconnect, and verifies that the per-origin pool cache is empty. It also verifies the failed-connection path.
Environment