fix: wrap kConnector call in try/catch to prevent client hang#4834
Open
veeceey wants to merge 1 commit intonodejs:mainfrom
Open
fix: wrap kConnector call in try/catch to prevent client hang#4834veeceey wants to merge 1 commit intonodejs:mainfrom
veeceey wants to merge 1 commit intonodejs:mainfrom
Conversation
When client[kConnector]() throws synchronously (e.g. from tls.connect with bad cert/key), the error was unhandled and left the client in a bad state where subsequent requests would hang indefinitely. Wrapping the call in try/catch with the same cleanup as the error callback (handleConnectError + kResume) restores proper error recovery. Fixes: nodejs#4697
Author
Manual test resultsTested with the repro from the issue: Before the fix, the second request would hang indefinitely. Now both requests throw the expected TLS error and the client stays in a usable state. Existing test suites pass:
|
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.
When
client[kConnector]()throws synchronously (e.g. fromtls.connectwith a bad cert/key), the error goes unhandled and leaves the client in a bad state where all subsequentclient.request()calls hang indefinitely.This wraps the
client[kConnector](...)invocation in a try/catch that performs the same cleanup as the error callback path — callinghandleConnectErrorandclient[kResume]()— so the client recovers properly and further requests can proceed.Repro from the issue:
Tested locally — both requests now throw the expected error and the client stays usable.
Fixes #4697