Skip to content

yarn doesn't properly report http errors when fetching packages #6735

@arcanis

Description

@arcanis

Do you want to request a feature or report a bug?
bug

What is the current behavior?
When an HTTP request for a tarball fails with a non-200 exit code (like 401 or 500), Yarn doesn't seem to properly catch it. This cause the error response to be treated as the tarball, which cause invalid reporting (usually "unexpected end of archive").

Also see:
This is the part of the code that's affected:
https://github.com/yarnpkg/yarn/blob/master/src/fetchers/tarball-fetcher.js#L231-L243

We provide a process option, so we never set the callback function that usually catch non-200 exit code:
https://github.com/yarnpkg/yarn/blob/master/src/util/request-manager.js#L407

If the current behavior is a bug, please provide the steps to reproduce.
It happens randomly based on the npm registry flakiness.

What is the expected behavior?
The error should say something like "Received an HTTP 500 from the server".

Please mention your node.js, yarn and operating system version.
1.12.3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions