You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
npm install appears to always use HttpProxyAgent instead of selecting between HttpProxyAgent and HttpsProxyAgent depending on the requested URL's protocol.
After #59, the library selects an HttpProxyAgent or HttpsProxyAgent based on an options.secureEndpoint property, but this appears to (always?) be undefined and not based on the url.protocol of the request.
I would expect npm install to use HttpProxyAgent when the requested url has an http protocol.
I would expect npm install to use HttpsProxyAgent when the requested url has an https protocol.
Steps To Reproduce
Use the latest node and npm, for example: node v21.3.0 (npm v10.2.4)
Configure .npmrc to use a proxy, for example:
https-proxy=<some proxy>
http-proxy=<some proxy>
Ensure an empty cache and install a package like uuid
$ npm cache clean --force
$ npm install -g uuid
Observe HttpProxyAgent is used to fetch an https url: 'https://registry.npmjs.org/uuid'
Observe the request's path is modified when using an HttpProxyAgent to setRequestProps for an https url. For example, the request.path is modified from '/uuid' to 'http://registry.npmjs.org:443/uuid'.
// it would be better to call proxy.addRequest here but this causes the
// http-proxy-agent to call its super.addRequest which causes the request
// to be added to the agent twice. since we only support 3 agents
// currently (see the required agents in proxy.js) we have manually
// checked that the only public methods we need to call are called in the
// next block. this could change in the future and presumably we would get
// failing tests until we have properly called the necessary methods on
// each of our proxy agents
if(proxy?.setRequestProps){
proxy.setRequestProps(request,options)
}
Note that the installation succeeds in the example above, but other registries appear to be less forgiving of the path change and this can cause installation issues in some cases.
Environment
npm: 10.2.4
Node: 21.3.0
OS: macOS 14.1.1
platform: macOS
The text was updated successfully, but these errors were encountered:
options.secureEndpoint is not always defined. There is however, a
function to properly identify the type of connection in the base
class, so intead of rolling the own check, relly on the base class
implementation.
Fixesnpm#87 and npm/cli#7024
Contributed by STMicroelectronics
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Is there an existing issue for this?
Current Behavior
Overview
I’ve noticed a behavior change in npm/agent v2.2.0 that shipped as part of npm/cli v10.2.0.
npm install
appears to always useHttpProxyAgent
instead of selecting betweenHttpProxyAgent
andHttpsProxyAgent
depending on the requested URL's protocol.Observations
I think I've isolated the behavior change to #59.
Prior to #59, it looks like the library would select an
HttpAgent
orHttpsAgent
based on theurl.protocol
of the request.agent/lib/index.js
Lines 20 to 30 in 22ac4e5
agent/lib/util.js
Lines 67 to 75 in 22ac4e5
After #59, the library selects an
HttpProxyAgent
orHttpsProxyAgent
based on anoptions.secureEndpoint
property, but this appears to (always?) be undefined and not based on theurl.protocol
of the request.agent/lib/index.js
Lines 26 to 36 in e24eb6c
agent/lib/agents.js
Lines 26 to 32 in e24eb6c
agent/lib/proxy.js
Lines 26 to 37 in e24eb6c
agent/lib/agents.js
Lines 64 to 72 in e24eb6c
Expected Behavior
npm install
to useHttpProxyAgent
when the requested url has anhttp
protocol.npm install
to useHttpsProxyAgent
when the requested url has anhttps
protocol.Steps To Reproduce
node v21.3.0 (npm v10.2.4)
.npmrc
to use a proxy, for example:uuid
HttpProxyAgent
is used to fetch anhttps
url:'https://registry.npmjs.org/uuid'
request
'spath
is modified when using anHttpProxyAgent
tosetRequestProps
for anhttps
url. For example, therequest.path
is modified from'/uuid'
to'http://registry.npmjs.org:443/uuid'
.agent/lib/agents.js
Lines 161 to 173 in e24eb6c
Environment
The text was updated successfully, but these errors were encountered: