| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #5441 +/- ##
==========================================
+ Coverage 93.44% 93.47% +0.02%
==========================================
Files 110 110
Lines 37078 37106 +28
==========================================
+ Hits 34649 34683 +34
+ Misses 2429 2423 -6 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
… looping When a proxy tore down the socket while the CONNECT tunnel was still being established, the inner client rejected with UND_ERR_SOCKET. The proxy-agent catch only special-cased ERR_TLS_CERT_ALTNAME_INVALID and passed every other error through raw. client.js#onError treats UND_ERR_SOCKET as a recoverable error on an established connection, so with no running request it left the request queued and connect() was re-driven forever, hammering the proxy while the request never settled. Wrap a tunnel-establishment socket failure in a new ProxyConnectionError (UND_ERR_PRX_CONN) so onError fails the request instead of retrying, mirroring the existing SecureProxyConnectionError handling for the TLS case. Fixes nodejs#3897
There was a problem hiding this comment.
lgtm
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This relates to...
Fixes #3897.
Rationale
If a proxy accepts the TCP connection but tears it down while the CONNECT tunnel is still being set up (a proxy that doesn't implement CONNECT, or that rejects the upstream), the request never settles and undici reconnects in a tight loop, hammering the proxy.
The inner client rejects the CONNECT with UND_ERR_SOCKET. The ProxyAgent connect override only had a special case for ERR_TLS_CERT_ALTNAME_INVALID and passed everything else through untouched. On the client side, onError treats UND_ERR_SOCKET as a recoverable error on an established connection, so with no running request it leaves the request queued and connect() gets re-driven over and over.
The TLS branch already sidesteps this by wrapping its error in SecureProxyConnectionError, with a comment that says exactly why ("to avoid loop in client.js#connect"). The plain socket case just never got the same treatment.
Changes
Wrap a socket failure during tunnel establishment in a new ProxyConnectionError (UND_ERR_PRX_CONN), so onError fails the request instead of retrying. The TLS branch and the fall-through for aborts and other errors are unchanged.
The fix is scoped to the proxy connect phase. It doesn't change how onError handles a socket drop on an already-established connection, which is a different case and stays recoverable.
Features
N/A
Bug Fixes
A proxy that drops the CONNECT tunnel now fails the request with ProxyConnectionError instead of reconnecting forever.
Breaking Changes and Deprecations
N/A. Adds a new errors.ProxyConnectionError.
Status