yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.72k forks source link

registry.yarnpkg.com responds with 503 error code quite frequently #7996

Open kaiyoma opened 4 years ago

kaiyoma commented 4 years ago

Bug description

Lately, I've been noticing that yarn audit fails quite often with a 503 error code from the upstream server. It seems to be random: running the command over and over sometimes works, sometimes fails.

Command

yarn audit

What is the current behavior? If I run with the verbose flag turned on, I see this:

verbose 2.2718308 Performing "POST" request to "https://registry.yarnpkg.com/-/npm/v1/security/audits".
verbose 15.5936641 Request "https://registry.yarnpkg.com/-/npm/v1/security/audits" finished with status code 503.
C:\Program Files (x86)\Yarn\lib\cli.js:66073
            throw new (_errors || _load_errors()).ResponseError(_this3.reporter.lang('requestFailed', description), res.
statusCode);
            ^

ResponseError: Request failed "503 Service Unavailable"

What is the expected behavior? No errors.

Environment

jakejarvis commented 4 years ago

Just happened to run into this running npm audit as well, for what it's worth.

npm ERR! code ENOAUDIT
npm ERR! audit Your configured registry (https://registry.npmjs.org/) may not support audit requests, or the audit endpoint may be temporarily unavailable.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jake/.npm/_logs/2020-03-17T18_09_56_254Z-debug.log

Shows registry.npmjs.org also returns 503 in the verbose logs, so this might be NPM's fault:

5 http fetch POST 503 https://registry.npmjs.org/-/npm/v1/security/audits 13190ms
kaiyoma commented 4 years ago

Seeing this again a lot right now. yarn audit is failing more than half the time with a 503 error.

waterkip commented 4 years ago

I have the same issue, but I'd like to add something to it in regards to the exit code. I don't mind the 503 (well I do), but I'm trying to do audit as part of a build process. I don't mind INFO or LOW, so I check if the return code is greater than 3 and continue. Because the 503 generates a return code of 1 my audit seems to complete just fine, as it is an "INFO".

Could you for the sake of scripting use a different exit code when a 503 enters? There is some kind of standard re exitcodes: http://www.tldp.org/LDP/abs/html/exitcodes.html, so I would propose 64.