fix: avoid sync callback in async function

This commit is contained in:
Jacob Heun 2018-12-19 13:49:33 -08:00
parent 35230c9800
commit dcb75824aa
No known key found for this signature in database
GPG Key ID: CA5A94C15809879F
2 changed files with 5 additions and 5 deletions

View File

@ -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",

View File

@ -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