From 4b1ebc7ee759824db97d1d64e8e5db32011e440f Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Mon, 25 Mar 2019 10:56:03 +0100 Subject: [PATCH] fix: destroy streams on end (#86) --- src/muxer.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/muxer.js b/src/muxer.js index f238afe..fcafc5e 100644 --- a/src/muxer.js +++ b/src/muxer.js @@ -39,7 +39,6 @@ module.exports = class Muxer extends EventEmitter { if (didError && /ok/i.test(didError.message)) { didError = false } - spdy.destroyStreams(new Error('underlying socket has been closed')) this.emit('close', didError) }) @@ -103,10 +102,9 @@ module.exports = class Muxer extends EventEmitter { } end (cb) { - cb = once(cb || noop) - this.spdy.once('error', (err) => { - cb(err) - }) + cb = cb ? once(cb) : noop + this.spdy.once('error', cb) + this.spdy.destroyStreams() this.spdy.end((err) => { if (err && /ok/i.test(err.message)) { return cb()