Skip to content

Commit

Permalink
Properly reports network errors (#6817)
Browse files Browse the repository at this point in the history
* Properly reports network errors

* Updates the changelog

* Fixes flow
  • Loading branch information
arcanis committed Dec 14, 2018
1 parent e987790 commit 024e9fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
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

0 comments on commit 024e9fe

Please sign in to comment.