Fails to install when proxy config is not a fully-qualified url
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.2k
- Forks
- 271
- Avg merge
- 23h 40m
- Merged PRs (30d)
- 2
Description
My corporate environment sets HTTPS proxies globally using the standard `HTTPS_PROXY` environment variable, however it **only** sets domain name and port. It does not specify a fully qualified URL:
`corporate.proxy.example.com:1234`
Git, NPM, and other packages I've run into handle this perfectly.
However, `node-pre-gyp` and `gyp` choke on this and throw an error, failing to install:
```
node-pre-gyp WARN download ignoring invalid "proxy" config setting: "corporate.proxy.example.com:1234"
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.9 and node@10.16.3 (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error tunneling socket could not be established, cause=connect EHOSTUNREACH 0.0.12.56:80 - Local (10.139.96.68:63009)
gyp WARN download ignoring invalid "proxy" config setting: "corporate.proxy.example.com:1234"
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: tunneling socket could not be established, cause=connect EHOSTUNREACH 0.0.12.56:80 - Local (10.139.96.68:63011)
gyp ERR! stack at ClientRequest.onError (/Users/c050004/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/tunnel-agent/index.js:177:17)
gyp ERR! stack at Object.onceWrapper (events.js:286:20)
gyp ERR! stack at ClientRequest.emit (events.js:198:13)
gyp ERR! stack at Socket.socketErrorListener (_http_client.js:392:9)
gyp ERR! stack at Socket.emit (events.js:198:13)
gyp ERR! stack at emitErrorNT (internal/streams/destroy.js:91:8)
gyp ERR! stack at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
gyp ERR! stack at process._tickCallback (internal/process/next_tick.js:63:19)
```
This can be traced to a hard-coded assumption in `node-pre-gyp` (and gyp?) [that the proxy string must be a URL prefixed with http(s)](https://github.com/mapbox/node-pre-gyp/blob/590da5603bb77df9583bfdc54d05d2267cadb364/lib/install.js#L69). This is an invalid assumption. gyp should either be prefixing the http/https or it should be offloading the work to an HTTP library to handle the proxy settings.
In fact, gyp may not even need to be managing this. [`request`](https://github.com/request/request#controlling-proxy-behaviour-using-environment-variables) will respect the `HTTP_PROXY` and `HTTPS_PROXY` environment variables.
If `node-pre-gyp` is going to take the responsibility of checking to see if the value is a URL, then shouldn't `node-pre-gyp` take the responsibility of trying to prefix with http/https?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/install.js around line 69, then trace how node-pre-gyp and gyp consume HTTPS_PROXY. Verify the behavior for a bare host-and-port proxy and compare it with the request library behavior mentioned in the issue. Done means installation no longer rejects that proxy configuration or routes through the wrong endpoint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100