Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in the Hosted Git resolver, where it would make an HTTP request even if a mirrored tarball is present. #2705

Conversation

chrisgavin
Copy link

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

git clone https://github.com/chrisgavin/fake-package
cd fake-package
yarn install
yarn install --offline

This fails before applying my patch, but succeeds afterwards.

@chrisgavin
Copy link
Author

I might also hesitantly suggest this resolves #1925.

@chrisgavin
Copy link
Author

It seems I broke some tests. Closing this until I get a chance to fix them.

@chrisgavin chrisgavin closed this Feb 16, 2017
@TimvdLippe
Copy link
Contributor

@chrisgavin The test failure on AppVeyor is also happening with other PRs, so I think it is unrelated to your PR 😄

@raymondwang
Copy link
Contributor

@chrisgavin: This seems to work, and it's the singular feature preventing me from switching over to Yarn today. Can you reopen? I'd be happy to contribute unit tests if you don't have time as necessary.

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.

3 participants