Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly reports network errors #6817

Merged
merged 3 commits into from Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#6712](https://github.com/yarnpkg/yarn/pull/6712) - [**Maël Nison**](https://twitter.com/arcanis)

- Properly reports the error codes when the npm registry throws 500's

[#6817](https://github.com/yarnpkg/yarn/pull/6817) - [**Maël Nison**](https://twitter.com/arcanis)

## 1.12.3

**Important:** This release contains a cache bump. It will cause the very first install following the upgrade to take slightly more time, especially if you don't use the [Offline Mirror](https://yarnpkg.com/blog/2016/11/24/offline-mirror/) feature. After that everything will be back to normal.
Expand Down
15 changes: 13 additions & 2 deletions src/util/request-manager.js
Expand Up @@ -498,8 +498,19 @@ export default class RequestManager {
req.on('data', queue.stillActive.bind(queue));
}

if (params.process) {
params.process(req, resolve, reject);
const process = params.process;
if (process) {
req.on('response', res => {
if (res.statusCode >= 200 && res.statusCode < 300) {
return;
}

const description = `${res.statusCode} ${http.STATUS_CODES[res.statusCode]}`;
reject(new ResponseError(this.reporter.lang('requestFailed', description), res.statusCode));

req.abort();
});
process(req, resolve, reject);
}
}

Expand Down