Fixing Yarn 1 error "unexpected end of file"

Posted . Visible to the public.

Our CI setup frequently sees this error while running yarn install:

yarn install v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz: unexpected end of file".
info If you think this is a bug, please open a bug report with the information provided in "/builds/projects/foo-app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

This error is caused by Yarn not retrying npm disconnects Show archive.org snapshot which will not be fixed in Yarn 1 Show archive.org snapshot .

Assuming you don't want to upgrade to Yarn 2 Show archive.org snapshot , here are some workarounds for Yarn 1.

Increase Yarn's network timeout

yarn config set network-timeout 600000 -g

Retry yarn install until it succeeds

The following will retry yarn install up to 5 times or until it succeeds.

yarn || yarn || yarn || yarn || yarn
Profile picture of Henning Koch
Henning Koch
Last edit
Dennis Schreiner
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2023-01-12 14:41)