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 <aras.abbasi@googlemail.com>
(cherry picked from commit f98fbef)
  • Loading branch information
hochoy authored and github-actions[bot] committed Nov 11, 2024
1 parent f21da44 commit 0f236cd
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 0f236cd

Please sign in to comment.