Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
fix: if replicate error, retry from official registry (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Oct 18, 2017
1 parent 43ffa99 commit 6c69a38
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions controllers/sync_module_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,26 @@ SyncModuleWorker.prototype.syncByName = function* (concurrencyId, name, registry
var errMessage = err.name + ': ' + err.message;
that.log('[c#%s] [error] [%s] get package(%s%s) error: %s, status: %s',
concurrencyId, name, registry, packageUrl, errMessage, status);
yield that._doneOne(concurrencyId, name, false);
return;
if (err.res.statusCode < 500 || registry !== config.officialNpmReplicate) {
// sync fail
yield that._doneOne(concurrencyId, name, false);
return;
}

// retry from officialNpmRegistry
this.log('[c#%d] [%s] retry from %s', concurrencyId, name, config.officialNpmRegistry);
try {
var result = yield npmSerivce.request(packageUrl, { registry: config.officialNpmRegistry });
pkg = result.data;
status = result.status;
} catch (err) {
var errMessage = err.name + ': ' + err.message;
that.log('[c#%s] [error] [%s] get package(%s%s) error: %s, status: %s',
concurrencyId, name, config.officialNpmRegistry, packageUrl, errMessage, status);
// sync fail
yield that._doneOne(concurrencyId, name, false);
return;
}
}
}

Expand Down

0 comments on commit 6c69a38

Please sign in to comment.