Skip to content

Commit

Permalink
msg.finished is only finished if socket has been detached
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jun 25, 2019
1 parent 08345db commit e73e839
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,15 @@ function onFinished (msg, listener) {
function isFinished (msg) {
var socket = msg.socket

if (msg.stream) {
// Http2ServerRequest
// Http2ServerResponse
return msg.stream.closed
}

if (typeof msg.finished === 'boolean') {
// OutgoingMessage
return Boolean(msg.finished || (socket && !socket.writable))
return Boolean((!socket && msg.finished && msg.outputSize === 0) || (socket && !socket.writable))
}

if (typeof msg.complete === 'boolean') {
Expand Down

0 comments on commit e73e839

Please sign in to comment.