Skip to content

Commit

Permalink
do max listener stuff to avoid those error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanong committed Aug 22, 2014
1 parent 471140f commit aa2aad5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion master.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ function Master(filename, options) {
var args = slice.call(arguments)
var proc = runner.select()
proc.queue++
proc._maxListeners++
var id = _id++

return new Promise(function (resolve, reject) {
proc.on('message', function onmessage(res) {
if (res.id !== id) return
proc.queue--
proc.removeListener('message', onmessage)
proc.queue--
proc._maxListeners--
if ('value' in res) return resolve(res.value)
else reject(JSONToError(res.error))
})
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Slave', function () {
})

var fns = []
for (var i = 0; i < 10; i++) (function (i) {
for (var i = 0; i < 100; i++) (function (i) {
fns.push(fn(i).then(function (val) {
assert.equal(val, i)
}))
Expand Down

0 comments on commit aa2aad5

Please sign in to comment.