net: deferred self.destroy calls in internalConnect(Multiple) to next…#51038
Closed
timothyjrogers wants to merge 1 commit intonodejs:mainfrom
timothyjrogers:48771-unhandled-net-exception
Closed
net: deferred self.destroy calls in internalConnect(Multiple) to next…#51038timothyjrogers wants to merge 1 commit intonodejs:mainfrom timothyjrogers:48771-unhandled-net-exception
timothyjrogers wants to merge 1 commit intonodejs:mainfrom
timothyjrogers:48771-unhandled-net-exception
Conversation
… tick self.destroy calls in the internalConnect adn internalConnectMultiple functions have a narrow case where they can throw before an error handler has been established. This change defers them to the next tick to allow time for the error handler to be set. Fixes: #48771
Collaborator
|
Review requested:
|
mcollina
reviewed
Dec 4, 2023
Member
There was a problem hiding this comment.
Could you add a test for this?
ShogunPanda
reviewed
Dec 4, 2023
Contributor
|
Once you add a test as @mcollina requested, it will LGTM. |
nodejs-github-bot
pushed a commit
that referenced
this pull request
Feb 6, 2026
Defer socket.destroy() calls in internalConnect and internalConnectMultiple to the next tick. This ensures that error handlers have a chance to be set up before errors are emitted, particularly important when using http.request with a custom lookup function that returns synchronously. Previously, if a synchronous lookup function returned an IP that triggered an immediate error (e.g., via blockList), the error would be emitted before the HTTP client had set up its error handler (which happens via process.nextTick in onSocket). This caused unhandled 'error' events. Fixes: #48771 PR-URL: #61658 Refs: #51038 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com>
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.
… tick
self.destroy calls in the internalConnect adn internalConnectMultiple functions have a narrow case where they can throw before an error handler has been established. This change defers them to the next tick to allow time for the error handler to be set.
Fixes: #48771