From dcb75824aa4a1271ce345a869b35b1745e74d522 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Wed, 19 Dec 2018 13:49:33 -0800 Subject: [PATCH] fix: avoid sync callback in async function --- package.json | 7 +++---- src/etm.js | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cc1ce99..4f00039 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "async": "^2.6.1", "debug": "^4.1.0", "interface-connection": "~0.3.2", - "libp2p-crypto": "~0.14.0", + "libp2p-crypto": "github:libp2p/js-libp2p-crypto#fix/async", "multihashing-async": "~0.5.1", "peer-id": "~0.12.0", - "peer-info": "~0.14.1", + "peer-info": "~0.15.0", "protons": "^1.0.1", "pull-defer": "~0.2.3", "pull-handshake": "^1.1.4", @@ -39,11 +39,10 @@ "pull-stream": "^3.6.9" }, "devDependencies": { - "aegir": "^17.0.1", + "aegir": "^17.1.1", "benchmark": "^2.1.4", "chai": "^4.2.0", "dirty-chai": "^2.0.1", - "gulp": "^3.9.1", "libp2p-websockets": "~0.12.0", "multistream-select": "~0.14.3", "pull-goodbye": "~0.0.2", diff --git a/src/etm.js b/src/etm.js index 02b75f4..dea3632 100644 --- a/src/etm.js +++ b/src/etm.js @@ -2,6 +2,7 @@ const pull = require('pull-stream') const lp = require('pull-length-prefixed') +const setImmediate = require('async/setImmediate') const lpOpts = { fixed: true, @@ -39,7 +40,7 @@ exports.createUnboxStream = (decipher, mac) => { const macSize = mac.length if (l < macSize) { - return cb(new Error(`buffer (${l}) shorter than MAC size (${macSize})`)) + return setImmediate(() => cb(new Error(`buffer (${l}) shorter than MAC size (${macSize})`))) } const mark = l - macSize