Skip to content

Commit

Permalink
Fix expected response when there's a socket error (#3597)
Browse files Browse the repository at this point in the history
In the case of a network issue, there's an error but no response, so no statusCode, This fixes it

Fixes #3594
  • Loading branch information
zxfrank committed Jan 29, 2021
1 parent 3c23217 commit 63c1827
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/less/src/less-node/url-file-manager.js
Expand Up @@ -27,8 +27,8 @@ UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr

request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {
if (err || resp.statusCode >= 400) {
const message = resp.statusCode === 404
if (err || resp && resp.statusCode >= 400) {
const message = resp && resp.statusCode === 404
? `resource '${urlStr}' was not found\n`
: `resource '${urlStr}' gave this Error:\n ${err || resp.statusMessage || resp.statusCode}\n`;
reject({ type: 'File', message });
Expand Down

0 comments on commit 63c1827

Please sign in to comment.