Skip to content

Commit

Permalink
fix: reduce pipelining client socket listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
calebboyd committed Apr 5, 2021
1 parent 21a136a commit fb4ef52
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ function attachFinishedListener (msg, callback) {
if (finished) return
if (eeMsg !== eeSocket) return

var attached = socket.__onFinished
if (!attached || !attached.queue) {
attached = socket.__onFinished = createListener(socket)
eeSocket = first([[socket, 'error', 'close']], attached)
}
// finished on first socket event
eeSocket = first([[socket, 'error', 'close']], onFinish)
attached.queue.push(onFinish)
}

if (msg.socket) {
// socket already assigned
onSocket(msg.socket)
defer(onSocket, msg.socket)
return
}

Expand Down

0 comments on commit fb4ef52

Please sign in to comment.