yarn icon indicating copy to clipboard operation
yarn copied to clipboard

Address `yarn audit` service reliability

Open jcollum-nike opened this issue 7 years ago • 17 comments

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)

jcollum-nike avatar Apr 15 '19 23:04 jcollum-nike

We use the npm registry to provide the audit data. There's unfortunately nothing we can do on our side.

arcanis avatar Apr 16 '19 12:04 arcanis

Could cache it.

jcollum-nike avatar Apr 16 '19 16:04 jcollum-nike

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.

arcanis avatar Apr 16 '19 17:04 arcanis

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).

jcollum-nike avatar Apr 19 '19 19:04 jcollum-nike

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.

arcanis avatar Apr 19 '19 20:04 arcanis

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.

jcollum-nike avatar Apr 19 '19 20:04 jcollum-nike

Just called it here and it seemed to work 🤷‍♀️

Feel free to make a suggestion, but I don't see anything I can do 🙁

arcanis avatar Apr 19 '19 20:04 arcanis

I'm out of ideas too. Darn.

jcollum-nike avatar Apr 19 '19 20:04 jcollum-nike

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

arcanis avatar Apr 19 '19 20:04 arcanis

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?

jedrichards avatar May 14 '19 09:05 jedrichards

There isn't a single issue on the npm repo, open or closed, related to audit service reliability that I can find:

Yes, very weird.

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?

arcanis avatar May 14 '19 09:05 arcanis

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.

jedrichards avatar May 14 '19 09:05 jedrichards

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 😒

arcanis avatar May 14 '19 10:05 arcanis

Oh gotcha, the npm community forum wasn't on my radar.

At the very least I'm glad we decided not to run audit by default on yarn install

Indeed! Dodged a bullet there 😅

jedrichards avatar May 14 '19 10:05 jedrichards

I would expect an HTTP

I expect a lot of HTTP codes that I don't get 😆

jcollum-nike avatar May 14 '19 16:05 jcollum-nike

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?

tangentially avatar Apr 02 '20 12:04 tangentially

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?

slawiko avatar May 08 '20 07:05 slawiko