diff --git a/package.json b/package.json index cf5d2f6..e677aa9 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "libp2p-tcp": "^0.11.5", "libp2p-websockets": "~0.10.4", "pre-commit": "^1.2.2", + "pull-abortable": "^4.1.1", "pull-pair": "^1.1.0" }, "dependencies": { diff --git a/src/muxer.js b/src/muxer.js index 6fe8415..95f679e 100644 --- a/src/muxer.js +++ b/src/muxer.js @@ -51,7 +51,12 @@ class MultiplexMuxer extends EventEmitter { // method added to enable pure stream muxer feeling newStream (callback) { callback = callback || noop - let stream = this.multiplex.createStream() + let stream + try { + stream = this.multiplex.createStream() + } catch (err) { + return setImmediate(callback(err)) + } const conn = new Connection( catchError(toPull.duplex(stream)),