Send local fetch error to verbose reporter before falling back to external fetch#6169
Open
itsananderson wants to merge 2 commits intoyarnpkg:masterfrom
Open
Send local fetch error to verbose reporter before falling back to external fetch#6169itsananderson wants to merge 2 commits intoyarnpkg:masterfrom
itsananderson wants to merge 2 commits intoyarnpkg:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Finally got a chance to put together a PR for the offline install enhancement (#5695) I submitted a few months ago.
Today, if Yarn is unable to install a package locally (local cache or offline mirror), it falls back to installing from an external source. However, if you've configured Yarn with
--offline, the external fetch immediately fails with an exception.What's tricky is the exception from
fetchFromLocalis swallowed, so the reason for the failure is lost. This makes it much harder to debug corrupted archives etc.This change updates the fallback to log the
fetchFromLocalexception to theverbosereporter, so that it can be viewed if the--verboseCLI flag was provided. I opted to print the error in 2 lines because formatting the actual error message directly into theerrorFetchingFromLocalmessage caused the final output to have\escapes for all the quotes, which reduced readability.Test plan
I first tested this with a missing package archive, which resulted in this output:
Then I tested with an intentionally corrupted archive, which produced this:
Since this diff is only adding verbose logging, it didn't make a ton of sense to add new tests, but if more tests are desired here, let me know!