diff --git a/index.js b/index.js index a6724cf..5810ce0 100644 --- a/index.js +++ b/index.js @@ -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') {