Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit faa51b4

Browse files
alanshawdaviddias
authored andcommittedMay 14, 2018
fix: use async/setImmediate vs process.nextTick
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent 1435655 commit faa51b4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
 

‎src/dag/put.js

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const dagCBOR = require('ipld-dag-cbor')
55
const promisify = require('promisify-es6')
66
const CID = require('cids')
77
const multihash = require('multihashes')
8+
const setImmediate = require('async/setImmediate')
89
const SendOneFile = require('../utils/send-one-file')
910

1011
function noop () {}

‎src/pubsub.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const promisify = require('promisify-es6')
44
const EventEmitter = require('events')
55
const eos = require('end-of-stream')
66
const isNode = require('detect-node')
7+
const setImmediate = require('async/setImmediate')
78
const PubsubMessageStream = require('./utils/pubsub-message-stream')
89
const stringlistToArray = require('./utils/stringlist-to-array')
910
const moduleConfig = require('./utils/module-config')
@@ -39,7 +40,7 @@ module.exports = (arg) => {
3940
return Promise.reject(NotSupportedError())
4041
}
4142

42-
return process.nextTick(() => callback(NotSupportedError()))
43+
return setImmediate(() => callback(NotSupportedError()))
4344
}
4445

4546
// promisify doesn't work as we always pass a
@@ -63,7 +64,7 @@ module.exports = (arg) => {
6364
return Promise.reject(NotSupportedError())
6465
}
6566

66-
return process.nextTick(() => callback(NotSupportedError()))
67+
return setImmediate(() => callback(NotSupportedError()))
6768
}
6869

6970
if (ps.listenerCount(topic) === 0 || !subscriptions[topic]) {
@@ -73,7 +74,7 @@ module.exports = (arg) => {
7374
return Promise.reject(err)
7475
}
7576

76-
return process.nextTick(() => callback(err))
77+
return setImmediate(() => callback(err))
7778
}
7879

7980
ps.removeListener(topic, handler)
@@ -88,7 +89,7 @@ module.exports = (arg) => {
8889
return Promise.resolve()
8990
}
9091

91-
process.nextTick(() => callback())
92+
setImmediate(() => callback())
9293
},
9394
publish: promisify((topic, data, callback) => {
9495
if (!isNode) {

0 commit comments

Comments
 (0)
This repository has been archived.