Skip to content

Commit

Permalink
fix: handle undefined deref() of WeakRef(socket) (#3751) (#3822)
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 <aras.abbasi@googlemail.com>
(cherry picked from commit f98fbef)

Co-authored-by: hochoy <hochoy@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and hochoy authored Nov 11, 2024
1 parent f21da44 commit 98d1b1b
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 98d1b1b

Please sign in to comment.