Skip to content

Commit

Permalink
fix: handle undefined deref() of WeakRef(socket) (#3751)
Browse files Browse the repository at this point in the history
* fix: handle undefined deref of weakref socket

* exit early

---------

Co-authored-by: Aras Abbasi <[email protected]>
  • Loading branch information
hochoy and Uzlopak authored Nov 11, 2024
1 parent 4d0eace commit f98fbef
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/core/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ const setupConnectTimeout = process.platform === 'win32'
* @param {number} opts.port
*/
function onConnectTimeout (socket, opts) {
// The socket could be already garbage collected
if (socket == null) {
return
}

let message = 'Connect Timeout Error'
if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) {
message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(', ')},`
Expand Down

0 comments on commit f98fbef

Please sign in to comment.