Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 0208504

Browse files
committed
fix: setImmediate erros as well, update interface-ipfs-core
1 parent 3082c2f commit 0208504

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"form-data": "^2.1.2",
7070
"fs-pull-blob-store": "^0.4.1",
7171
"gulp": "^3.9.1",
72-
"interface-ipfs-core": "^0.23.2",
72+
"interface-ipfs-core": "^0.23.3",
7373
"ipfsd-ctl": "^0.18.1",
7474
"left-pad": "^1.1.3",
7575
"lodash": "^4.17.4",

src/core/components/pubsub.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,20 @@ module.exports = function pubsub (self) {
4444

4545
publish: promisify((topic, data, callback) => {
4646
if (!self.isOnline()) {
47-
throw OFFLINE_ERROR
47+
return setImmediate(() => callback(OFFLINE_ERROR))
4848
}
4949

5050
if (!Buffer.isBuffer(data)) {
51-
return callback(new Error('data must be a Buffer'))
51+
return setImmediate(() => callback(new Error('data must be a Buffer')))
5252
}
5353

5454
self._pubsub.publish(topic, data)
55-
56-
setImmediate(callback)
55+
setImmediate(() => callback())
5756
}),
5857

5958
ls: promisify((callback) => {
6059
if (!self.isOnline()) {
61-
throw OFFLINE_ERROR
60+
return setImmediate(() => callback(OFFLINE_ERROR))
6261
}
6362

6463
const subscriptions = Array.from(
@@ -70,7 +69,7 @@ module.exports = function pubsub (self) {
7069

7170
peers: promisify((topic, callback) => {
7271
if (!self.isOnline()) {
73-
throw OFFLINE_ERROR
72+
return setImmediate(() => callback(OFFLINE_ERROR))
7473
}
7574

7675
const peers = Array.from(self._pubsub.peers.values())
@@ -93,6 +92,6 @@ module.exports = function pubsub (self) {
9392
}
9493

9594
ps.on(topic, handler)
96-
setImmediate(callback)
95+
setImmediate(() => callback())
9796
}
9897
}

0 commit comments

Comments
 (0)