Skip to content

Commit

Permalink
fix: don't set socket on client before init
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag authored and crysmags committed Feb 27, 2024
1 parent b91963b commit a1322fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,6 @@ async function connect (client) {

assert(socket)

client[kSocket] = socket

socket[kNoRef] = false
socket[kWriting] = false
socket[kReset] = false
Expand All @@ -1091,6 +1089,8 @@ async function connect (client) {
.on('end', onSocketEnd)
.on('close', onSocketClose)

client[kSocket] = socket

if (channels.connected.hasSubscribers) {
channels.connected.publish({
connectParams: {
Expand Down Expand Up @@ -1176,7 +1176,7 @@ function _resume (client, sync) {

const socket = client[kSocket]

if (socket) {
if (socket && !socket.destroyed) {
if (client[kSize] === 0) {
if (!socket[kNoRef] && socket.unref) {
socket.unref()
Expand Down Expand Up @@ -1243,7 +1243,7 @@ function _resume (client, sync) {

if (!socket) {
connect(client)
continue
return
}

if (socket.destroyed || socket[kWriting] || socket[kReset] || socket[kBlocking]) {
Expand Down

0 comments on commit a1322fd

Please sign in to comment.