From e188047cfbe22cfd761ac8a77dac72b635509023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Cruz?= Date: Mon, 3 Jun 2013 16:49:40 +0100 Subject: [PATCH] Fix fail fast mechanism. --- lib/core/Manager.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/core/Manager.js b/lib/core/Manager.js index 4567c417..91e82650 100644 --- a/lib/core/Manager.js +++ b/lib/core/Manager.js @@ -61,7 +61,7 @@ Manager.prototype.resolve = function () { this._fetching = {}; this._nrFetching = 0; this._failed = {}; - this._failFast = false; + this._hasFailed = false; this._deferred = Q.defer(); // If there's nothing to resolve, simply dissect @@ -184,8 +184,8 @@ Manager.prototype._fetch = function (decEndpoint) { var name = decEndpoint.name; var logger; - // Check if the whole process is marked to fail fast - if (this._failFast) { + // Check if the whole process started to fail fast + if (this._hasFailed) { return; } @@ -271,7 +271,7 @@ Manager.prototype._onFetchError = function (decEndpoint, err) { delete decEndpoint.promise; // Make the whole process to fail fast - this._failFast = true; + this._failFast(); // If the resolve process ended, parse the resolved packages // to find the most suitable version for each package @@ -281,11 +281,11 @@ Manager.prototype._onFetchError = function (decEndpoint, err) { }; Manager.prototype._failFast = function () { - if (this._failFast) { + if (this._failFastTimeout) { return; } - this._failFast = true; + this._hasFailed = true; // If after 20 seconds all pending tasks haven't finished, // we force the process to end @@ -295,7 +295,6 @@ Manager.prototype._failFast = function () { }.bind(this), 20000); }; - Manager.prototype._parseDependencies = function (decEndpoint, pkgMeta) { // Parse package dependencies mout.object.forOwn(pkgMeta.dependencies, function (value, key) { @@ -352,7 +351,7 @@ Manager.prototype._dissect = function () { // If something failed, reject the whole resolve promise // with the first error - if (this._failFast) { + if (this._hasFailed) { clearTimeout(this._failFastTimeout); // Cancel fail fast timeout err = mout.object.values(this._failed)[0][0];