diff options
author | Mickael van der Beek <mickael@sagacify.com> | 2014-11-18 21:20:56 +0100 |
---|---|---|
committer | Mickael van der Beek <mickael@sagacify.com> | 2014-11-18 21:20:56 +0100 |
commit | 2410077e26d5429ac45533438f008706dcb989f7 (patch) | |
tree | 7f256954934f46a8efbebeb0f456b399f0d96ea4 /lib | |
parent | 232121251f601c9be7209f6382ee32180df676f1 (diff) | |
download | async-2410077e26d5429ac45533438f008706dcb989f7.tar.gz |
Fixes caolan/async#263 and other dependency issues by detecting dead-locks and throwing an Error.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/async.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/async.js b/lib/async.js index a13f835..50f7a28 100755 --- a/lib/async.js +++ b/lib/async.js @@ -478,6 +478,17 @@ } }; var requires = task.slice(0, Math.abs(task.length - 1)) || []; + // prevent dead-locks + var len = requires.length; + var dep; + while (len--) { + if (!(dep = tasks[requires[len]])) { + throw new Error('Has inexistant dependency'); + } + if (_isArray(dep) && !!~dep.indexOf(k)) { + throw new Error('Has cyclic dependencies'); + } + } var ready = function () { return _reduce(requires, function (a, x) { return (a && results.hasOwnProperty(x)); |