fix(socks5-proxy-agent): destroy socket when negotiation times out - #5709
Merged
metcoder95 merged 1 commit intoAug 25, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5709 +/- ##
=======================================
Coverage 93.47% 93.47%
=======================================
Files 110 110
Lines 38906 38908 +2
=======================================
+ Hits 36366 36370 +4
+ Misses 2540 2538 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
metcoder95
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When SOCKS5 authentication or connection negotiation times out,
createSocks5Connection()rejects its promise but never destroys the underlying socket. The socket also never reaches the per-origin pool because the connect callback is only invoked on success, soclose()anddestroy()cannot reach it and it stays open for the lifetime of the process. This destroys the client in both timeout branches before rejecting.Testing
Reproduced with a local TCP proxy that accepts a connection but never replies to the greeting: the request rejects with "SOCKS5 authentication timeout", after which
agent.close()leaves the socket open. Added a regression test intest/socks5-proxy-agent.jsthat asserts the connector socket is destroyed after close; it fails without this change and passes with it. All socks5 test files pass (33 pass, 1 skipped) and eslint is clean.Checklist