diff --git a/package.json b/package.json index 31e5a7ef59..a3589b518e 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "form-data": "^2.1.2", "fs-pull-blob-store": "^0.4.1", "gulp": "^3.9.1", - "interface-ipfs-core": "^0.23.2", + "interface-ipfs-core": "^0.23.3", "ipfsd-ctl": "^0.18.1", "left-pad": "^1.1.3", "lodash": "^4.17.4", diff --git a/src/core/components/pubsub.js b/src/core/components/pubsub.js index 997559928e..b0a1eb283d 100644 --- a/src/core/components/pubsub.js +++ b/src/core/components/pubsub.js @@ -44,21 +44,20 @@ module.exports = function pubsub (self) { publish: promisify((topic, data, callback) => { if (!self.isOnline()) { - throw OFFLINE_ERROR + return setImmediate(() => callback(OFFLINE_ERROR)) } if (!Buffer.isBuffer(data)) { - return callback(new Error('data must be a Buffer')) + return setImmediate(() => callback(new Error('data must be a Buffer'))) } self._pubsub.publish(topic, data) - - setImmediate(callback) + setImmediate(() => callback()) }), ls: promisify((callback) => { if (!self.isOnline()) { - throw OFFLINE_ERROR + return setImmediate(() => callback(OFFLINE_ERROR)) } const subscriptions = Array.from( @@ -70,7 +69,7 @@ module.exports = function pubsub (self) { peers: promisify((topic, callback) => { if (!self.isOnline()) { - throw OFFLINE_ERROR + return setImmediate(() => callback(OFFLINE_ERROR)) } const peers = Array.from(self._pubsub.peers.values()) @@ -93,6 +92,6 @@ module.exports = function pubsub (self) { } ps.on(topic, handler) - setImmediate(callback) + setImmediate(() => callback()) } }