Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: fix autoSelectFamily close behavior
If the first connection is successful, but only after the connect timeout, and all subsequent connections result in an error, the socket will not emit the 'close' event, causing issues in places like 'http's 'Agent' which rely on the 'close' event to free up sockets. This commit moves the reassignment of '_handle' to happen as soon as a new connection is attempted, so that if the socket is destroyed, the '_handle' will represent the last connection attempt (even if it resulted in an error) and closing the handle will then cause the 'close' event to be emitted. See npm/cli#6409 for more background.
- Loading branch information