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

Commit

Permalink
fix: use async/setImmediate vs process.nextTick
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <[email protected]>
  • Loading branch information
alanshaw authored and daviddias committed May 14, 2018
1 parent 1435655 commit faa51b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const dagCBOR = require('ipld-dag-cbor')
const promisify = require('promisify-es6')
const CID = require('cids')
const multihash = require('multihashes')
const setImmediate = require('async/setImmediate')
const SendOneFile = require('../utils/send-one-file')

function noop () {}
Expand Down
9 changes: 5 additions & 4 deletions src/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const promisify = require('promisify-es6')
const EventEmitter = require('events')
const eos = require('end-of-stream')
const isNode = require('detect-node')
const setImmediate = require('async/setImmediate')
const PubsubMessageStream = require('./utils/pubsub-message-stream')
const stringlistToArray = require('./utils/stringlist-to-array')
const moduleConfig = require('./utils/module-config')
Expand Down Expand Up @@ -39,7 +40,7 @@ module.exports = (arg) => {
return Promise.reject(NotSupportedError())
}

return process.nextTick(() => callback(NotSupportedError()))
return setImmediate(() => callback(NotSupportedError()))
}

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

return process.nextTick(() => callback(NotSupportedError()))
return setImmediate(() => callback(NotSupportedError()))
}

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

return process.nextTick(() => callback(err))
return setImmediate(() => callback(err))
}

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

process.nextTick(() => callback())
setImmediate(() => callback())
},
publish: promisify((topic, data, callback) => {
if (!isNode) {
Expand Down

0 comments on commit faa51b4

Please sign in to comment.