Skip to content

Commit

Permalink
Timeout hint (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
raineorshine committed Mar 28, 2020
1 parent c296de9 commit 6b34206
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/versionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const semver = require('semver');
const _ = require('lodash');
const cint = require('cint');
const chalk = require('chalk');
const semverutils = require('semver-utils');
const ProgressBar = require('progress');
const versionUtil = require('./version-util.js');
Expand Down Expand Up @@ -433,9 +434,16 @@ function queryVersions(packageMap, options = {}) {
pre: options.pre != null ? options.pre : versionUtil.isPre(packageMap[dep])
}
)).catch(err => {
if (err && (err.message || err).toString().match(/E404|ENOTFOUND|404 Not Found/i)) {
const errorMessage = err ? (err.message || err).toString() : '';
if (errorMessage.match(/E404|ENOTFOUND|404 Not Found/i)) {
return null;
} else {

// print a hint about the --timeout option for network timeout errors
if (/(Response|network) timeout/i.test(errorMessage)) {
console.error('\n\n' + chalk.red('FetchError: Request Timeout. npm-registry-fetch defaults to 30000 (30 seconds). Try setting the --timeout option (in milliseconds) to override this.') + '\n');
}

throw err;
}
}).then(result => {
Expand Down

0 comments on commit 6b34206

Please sign in to comment.