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

https-agent makes http PUPPETEER_DOWNLOAD_HOST download fail #4556

Closed
tenuki opened this issue Jun 10, 2019 · 0 comments · Fixed by #4558
Closed

https-agent makes http PUPPETEER_DOWNLOAD_HOST download fail #4556

tenuki opened this issue Jun 10, 2019 · 0 comments · Fixed by #4558

Comments

@tenuki
Copy link
Contributor

tenuki commented Jun 10, 2019

Steps to reproduce

Environment

  • Puppeteer version: 4bcdfc9 (master as of June/10/19)
  • Platform / OS version: linux debian
  • URLs (if applicable): -
  • Node.js version: v12.3.1

Steps to reproduce:

http_proxy=http://localhost:3128 PUPPETEER_DOWNLOAD_HOST=http://storage.googleapis.com node install.js

Comments:

  • http_proxy above points to a working proxy.
  • I execute install.js from an installed version, as a way to reproduce the issue. But the first issue is npm install puppeteer with the same proxy and host as above.
  • YES I put http://storage.googleapis.com on purpose, that is when the issue happens. Actually, the repo I pretend to use will be in a http server and that is why I have the problem. In the example, I used googles' as it works for manual download and is enough to reproduce the problem.

Please include code that reproduces the issue.

  1. http_proxy=http://localhost:3128 PUPPETEER_DOWNLOAD_HOST=http://storage.googleapis.com node install.js

or:

  1. http_proxy=http://localhost:3128 PUPPETEER_DOWNLOAD_HOST=http://storage.googleapis.com npm install puppeteer

What is the expected result?

The http proxy will be used to download the chromium version from the specified $PUPPETEER_DOWNLOAD_HOST host.

What happens instead?

user@host:~/repos/puppeteer$ http_proxy=http://localhost:3128 PUPPETEER_DOWNLOAD_HOST=http://storage.googleapis.com node install.js
ERROR: Failed to download Chromium r666595! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
Error: Download failed: server returned code 403. URL: http://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/666595/chrome-linux.zip
    at /home/user/repos/puppeteer/lib/BrowserFetcher.js:232:21
    at ClientRequest.requestCallback (/home/user/repos/puppeteer/lib/BrowserFetcher.js:288:7)
    at Object.onceWrapper (events.js:288:20)
    at ClientRequest.emit (events.js:200:13)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:573:23)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:17)
    at Socket.socketOnData (_http_client.js:460:22)
    at Socket.emit (events.js:200:13)
    at ClientRequest.onsocket (/home/user/node_modules/https-proxy-agent/index.js:181:14)
    at Object.onceWrapper (events.js:288:20)
  -- ASYNC --
    at BrowserFetcher.<anonymous> (/home/user/repos/puppeteer/lib/helper.js:111:15)
    at Object.<anonymous> (/home/user/repos/puppeteer/install.js:64:16)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11
user@host:~/repos/puppeteer$

It should be noted that https-proxy-agent isn't meant to be used when the target download is http-served, see:

$ http_proxy=http://localhost:3128 node test.js http://example.com
using proxy server "http://localhost:3128"
attempting to GET "http://example.com"
_http_client.js:142
    throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
    ^

TypeError [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
    at new ClientRequest (_http_client.js:142:11)
    at Object.request (https.js:305:10)
    at Object.request (/tmp/tmp2/node_modules/agent-base/patch-core.js:25:22)
    at Object.https.get (/tmp/tmp2/node_modules/agent-base/patch-core.js:48:21)
    at Object.<anonymous> (/tmp/tmp2/node_modules/puppeteer/test.js:18:7)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
aslushnikov pushed a commit that referenced this issue Jun 10, 2019
…ST (#4558)

This patch avoids https-proxy-agent usage when target host protocol is http and proxy is specified.
This is a valid scenario for installer but was failing.

Fixes #4556
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant