diff --git a/src/index.js b/src/index.js index aea2fd1..1f20d48 100644 --- a/src/index.js +++ b/src/index.js @@ -108,7 +108,7 @@ function Swarm (peerInfo) { if (this.muxedConns[key]) { const muxer = this.muxedConns[key].muxer muxer.end() - muxer.on('close', () => { + muxer.once('close', () => { delete this.muxedConns[key] callback() }) diff --git a/test/09-swarm-with-muxing.node.js b/test/09-swarm-with-muxing.node.js index 2c87d9f..aa15bba 100644 --- a/test/09-swarm-with-muxing.node.js +++ b/test/09-swarm-with-muxing.node.js @@ -218,7 +218,7 @@ describe('high level API - with everything mixed all together!', function () { const ready = () => ++count === 3 ? done() : null swarmB.once('peer-mux-closed', (peerInfo) => { - expect(Object.keys(swarmA.muxedConns).length).to.equal(0) + expect(Object.keys(swarmB.muxedConns).length).to.equal(0) ready() })