Skip to content

Conversation

@arcanis
Copy link
Member

@arcanis arcanis commented Sep 21, 2018

Summary

Supersedes #6400, #6383

This PR adds a retry mechanism for when the npm registry returns 408 / 500 errors.

Test plan

Added a test. Hopefully our own CI will become more stable as well.

Copy link

@Ojisama Ojisama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be so boring, but why wouldn't we warn the user or make the command fail when a 4xx is received from the server? Issue #6359 wouldn't be solved by only checking res.statusCode >= 500 I'm afraid 😁

}

if (res.statusCode === 403) {
if ([403, 408].indexOf() !== -1 || res.statusCode >= 500) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't res.statusCode mising in the indexOf()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it totally does ... Flow should have warned me 😞

@arcanis
Copy link
Member Author

arcanis commented Sep 21, 2018

No worry! I updated the code to take all >=400 into account. Only 408 and >=500 will trigger a retry, though, to match what the npm client is doing to their servers.

@arcanis arcanis merged commit 454986b into yarnpkg:master Sep 25, 2018
@jmorrell
Copy link
Contributor

Glad to see this merged! Thanks for your work here @arcanis 🙏

jmorrell pushed a commit to heroku/heroku-buildpack-nodejs that referenced this pull request Sep 26, 2018
Now that 1.11.0 is released with yarnpkg/yarn#6413 merged,
Heroku users should see fewer failed builds due to 500 responses from
the registry.
jmorrell pushed a commit to heroku/heroku-buildpack-nodejs that referenced this pull request Oct 3, 2018
Now that 1.11.0 is released with yarnpkg/yarn#6413 merged,
Heroku users should see fewer failed builds due to 500 responses from
the registry.
jmorrell added a commit to heroku/heroku-buildpack-nodejs that referenced this pull request Oct 3, 2018
Now that 1.11.0 is released with yarnpkg/yarn#6413 merged,
Heroku users should see fewer failed builds due to 500 responses from
the registry.
@whereisaaron
Copy link

Hi @arcanis, this retry mechanism is very welcome thank you! However the retry message is I think a little misleading and IMO very annoying 😄

Given this mechanism is mostly to address congenital unreliability of the npm registries, is it fair that the message suggests it is the user's local network that is the problem?

offlineRetrying: 'There appears to be trouble with your network connection. Retrying...' 

Users are like, 'what do you mean my network has a problem, I have a gazillion-bit connection with zero drops!'. And they are looking for faults and problems in their network and for bugs in yarn, when we know neither is likely the cause. Could you consider revising or crafting a more appropriate message for this type of retry?

Also, given this retry requirement is congenital (I get multiple of this message with every yarn install now), it is basically normal operation. Do do users even need to hear about these retries unless the retires aren't working?

@arcanis
Copy link
Member Author

arcanis commented Oct 19, 2018

Hey @whereisaaron - the error message should be more explicit than what you quote. Cf here:

https://github.com/yarnpkg/yarn/pull/6413/files#diff-49d57266c25cd3c6ddab1f59de18b36bR24

Note that this PR is only part of the 1.11 and 1.12 branches, which are yet in prerelease.

@whereisaaron
Copy link

Thanks @arcanis that message does look much better - I had thought we were seeing the message from this line of your patch - which was the one I was quoting.
https://github.com/yarnpkg/yarn/pull/6413/files#diff-5d246f90b159bd84bbc99f67527b1a0eR401

Great - so hopefully when we get 1.11 we'll see the current messages replaced with your new, more accurate message. 🎉

erik-singleton pushed a commit to erik-singleton/yarn that referenced this pull request Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants