diff options
Diffstat (limited to 'deps/npm/node_modules/inflight/inflight.js')
-rw-r--r-- | deps/npm/node_modules/inflight/inflight.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/deps/npm/node_modules/inflight/inflight.js b/deps/npm/node_modules/inflight/inflight.js index 8bc96cbd37..48202b3ca4 100644 --- a/deps/npm/node_modules/inflight/inflight.js +++ b/deps/npm/node_modules/inflight/inflight.js @@ -19,18 +19,28 @@ function makeres (key) { var cbs = reqs[key] var len = cbs.length var args = slice(arguments) - for (var i = 0; i < len; i++) { - cbs[i].apply(null, args) - } - if (cbs.length > len) { - // added more in the interim. - // de-zalgo, just in case, but don't call again. - cbs.splice(0, len) - process.nextTick(function () { - RES.apply(null, args) - }) - } else { - delete reqs[key] + + // XXX It's somewhat ambiguous whether a new callback added in this + // pass should be queued for later execution if something in the + // list of callbacks throws, or if it should just be discarded. + // However, it's such an edge case that it hardly matters, and either + // choice is likely as surprising as the other. + // As it happens, we do go ahead and schedule it for later execution. + try { + for (var i = 0; i < len; i++) { + cbs[i].apply(null, args) + } + } finally { + if (cbs.length > len) { + // added more in the interim. + // de-zalgo, just in case, but don't call again. + cbs.splice(0, len) + process.nextTick(function () { + RES.apply(null, args) + }) + } else { + delete reqs[key] + } } }) } |