diff --git a/tools/catalog.js b/tools/catalog.js index 6103a6e770..6b196b7d53 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -88,8 +88,13 @@ catalog.refreshOrWarn = function (options) { catalog.runAndRetryWithRefreshIfHelpful = function (attempt) { buildmessage.assertInJob(); + var canRetry = ! (catalog.triedToRefreshRecently || + catalog.official.offline); + // Run `attempt` in a nested buildmessage context. - var messages = buildmessage.capture(attempt); + var messages = buildmessage.capture(function () { + attempt(canRetry); + }); // Did it work? Great. if (! messages.hasMessages()) { @@ -100,9 +105,7 @@ catalog.runAndRetryWithRefreshIfHelpful = function (attempt) { // related to that, or because we tried to refresh recently, or because we're // not allowed to refresh? Fail, merging the result of these errors into the // current job. - if (! messages.hasMessageWithTag('refreshCouldHelp') || - catalog.triedToRefreshRecently || - catalog.official.offline) { + if (! (messages.hasMessageWithTag('refreshCouldHelp') && canRetry)) { buildmessage.mergeMessagesIntoCurrentJob(messages); return; } @@ -131,7 +134,7 @@ catalog.runAndRetryWithRefreshIfHelpful = function (attempt) { } // Try again, this time directly in the current buildmessage job. - attempt(); + attempt(false); // canRetry = false }; // As a work-around for [] !== [], we use a function to check whether values are acceptable diff --git a/tools/project-context.js b/tools/project-context.js index 2383bdb73e..a3ca4e5efd 100644 --- a/tools/project-context.js +++ b/tools/project-context.js @@ -396,11 +396,9 @@ _.extend(ProjectContext.prototype, { var anticipatedPrereleases = self._getAnticipatedPrereleases( depsAndConstraints.constraints, cachedVersions); - var isFirstAttempt = true; - // Nothing before this point looked in the official or project catalog! // However, the resolver does, so it gets run in the retry context. - catalog.runAndRetryWithRefreshIfHelpful(function () { + catalog.runAndRetryWithRefreshIfHelpful(function (canRetry) { buildmessage.enterJob("selecting package versions", function () { var resolver = self._buildResolver(); @@ -415,7 +413,7 @@ _.extend(ProjectContext.prototype, { // of it yet. It's not actually fatal, though, for previousSolution // to refer to package versions that we don't have access to or don't // exist. They'll end up getting changed or removed if possible. - missingPreviousVersionIsError: isFirstAttempt + missingPreviousVersionIsError: canRetry }; if (self._upgradePackageNames) resolveOptions.upgrade = self._upgradePackageNames; @@ -448,8 +446,6 @@ _.extend(ProjectContext.prototype, { self._completedStage = STAGE.RESOLVE_CONSTRAINTS; }); - - isFirstAttempt = false; }); },