Fix a bug in the Hosted Git resolver, where it would make an HTTP request even if a mirrored tarball is present. #2705
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
After mirroring a package locally, specifically web-component-tester and attempting to install the dependency offline from the mirror I discovered Yarn makes an HTTP request. This means the installation fails if you pass
--offline
to Yarn or don't have an internet connection.If in offline mode the error "Can't make a request in offline mode" is displayed, otherwise an error about being unable to resolve github.com is shown.
It appears this problem occurs because the package in question references a shorthand GitHub dependency (
"test-fixture": "PolymerElements/test-fixture"
). A URL for this is created which gets passed through the hosted Git resolver. The hosted Git resolver then attempts to determine if this URL "hasHTTPCapability" by making a request to it. This fails in offline mode.The fix I have made here is simply to assert that the URL "hasHTTPCapability" if a mirror tarball for it exists. Sorry if this is not the right fix, but I am not very familiar with the codebase so I tried to make the simplest change possible.
Test plan
This fails before applying my patch, but succeeds afterwards.