Address `yarn audit` service reliability
I run this as part of my pre-push script: yarn audit | grep "high" | wc -l | tr -d ' ' -- that way high vulnerability packages won't get into my codebase without some warnings.
I've been getting 503s on this service for about 20 minutes now. This service is frequently unavailable, which makes me think I shouldn't rely on it.
I think higher reliability for this service is a reasonable thing to ask for.
throw new (_errors || _load_errors()).ResponseError(_this3.reporter.lang('requestFailed', description), res.statusCode);
^
Error: Request failed "503 Service Unavailable"
at ResponseError.ExtendableBuiltin (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:696:66)
at new ResponseError (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:802:124)
at Request.params.callback [as _callback] (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:66040:19)
at Request.self.callback (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:129541:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:130513:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:130435:12)
We use the npm registry to provide the audit data. There's unfortunately nothing we can do on our side.
Could cache it.
We are not very interested in dealing with server issues. The yarn registry hostname is only used as a safety valve at the moment in case the npm registry was to disappear for a reason or another.
I think this should be reopened. Something is going on with yarn audit while npm audit is running fine. Ran this just now in one project that uses yarn.lock and one project that uses package-lock.json:
package-lock.json:
=== npm audit security report ===
found 0 vulnerabilities
in 850808 scanned packages
yarn.lock:
yarn audit v1.15.2
warning Resolution field "[email protected]" is incompatible with requested version "js-yaml@~3.5.2"
/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:66040
throw new (_errors || _load_errors()).ResponseError(_this3.reporter.lang('requestFailed', description), res.statusCode);
^
Error: Request failed "503 Service Unavailable"
at ResponseError.ExtendableBuiltin (/Users/jcol53/.nvm/versions/node/v8.15.1/lib/node_modules/yarn/lib/cli.js:696:66)
If yarn audit is just pulling data from the npm registry, why is the npm service not affected?
Verified that this happens on my work network and my phone's mobile hotspot (to isolate the work network as a potential culprit).
If yarn audit is just pulling data from the npm registry, why is the npm service not affected?
I don't know, but a 503 is not actionnable for us. It definitely comes from the endpoint.
For the record the npm registry is definitely not the stablest piece of code ever .. I literally just got a 500 when publishing a package two minutes ago. From time to time there are also periods of increased instability, so I'd say it's likely to be the case here ... that, or it may be a way they rate limit us. I'd be surprised if that was the case though since that's not what the error code suggests.
From time to time there are also periods of increased instability, so I'd say it's likely to be the case here
That doesn't fit what I'm seeing. Yarn audit is failing, npm audit is succeeding. It's happened every time I've attempted it in the past 2 hours.
I just ran it again and the same thing happened.
Just called it here and it seemed to work 🤷♀️
Feel free to make a suggestion, but I don't see anything I can do 🙁
I'm out of ideas too. Darn.
Something you can try: find the following line in your Yarn file, and change it to the real registry (registry.npmjs.org). Does it work better?
https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/audit.js#L245
There isn't a single issue on the npm repo, open or closed, related to audit service reliability that I can find:
https://github.com/npm/cli/search?p=1&q=audit&type=Issues&unscoped_q=audit
But a whole bunch on here. It's a bit weird, no?
There isn't a single issue on the npm repo, open or closed, related to audit service reliability that I can find:
Regardless, my position is still the same: if a request sometimes work and sometimes doesn't, it's not a client problem. If it's not a client problem, there's nothing we can do. Makes sense?
Agreed. I guess my comment was in relation to your comment:
... that, or it may be a way they rate limit us. I'd be surprised if that was the case though since that's not what the error code suggests.
Sorry, should have made that explicit.
I see - well, it's very possible, but I would expect an HTTP 429 in this case ... 🤔
Looking at their community forum it sounds like a recurrent problem for the npm cli as well: https://npm.community/t/enoaudit-from-registry-npmjs-org-503/4642/42
At the very least I'm glad we decided not to run audit by default on yarn install ... a significant chunk of them would have crashed purely because of it 😒
Oh gotcha, the npm community forum wasn't on my radar.
At the very least I'm glad we decided not to run
auditby default onyarn install
Indeed! Dodged a bullet there 😅
I would expect an HTTP
I expect a lot of HTTP codes that I don't get 😆
Still an issue. status.npmjs shows "All Systems Operational". Is there another way to work around this maybe and have yarn somehow submit directly to the npm server directly instead of via proxy?
I also noticed it. Last few months our CI plan (regular yarn audit) is constantly failing with 503. Do you know what could be wrong?