travelaudience / nexus-proxy

A proxy for Nexus Repository Manager that allows for optional authentication against external identity providers.
Apache License 2.0
31 stars 16 forks source link

npm error HPE_UNEXPECTED_CONTENT_LENGTH #20

Open RenaudDemarneffe opened 5 years ago

RenaudDemarneffe commented 5 years ago

Hello,

I deployed Nexus OSS with nexus-proxy on a k8s cluster through the helm chart. I don't use GCP IAM authentication. I followed the documentation to configure the npm repositories.

When I try to download a package, I got the error HPE_UNEXPECTED_CONTENT_LENGTH.

The full error stack is the following:

[vmuser@Centos tmp]$ npm --registry http://www.exemple.com/repository/npm-group/ install generator-exemple-flak-api --loglevel verbose npm info it worked if it ends with ok npm verb cli [ npm verb cli '/usr/bin/node', npm verb cli '/usr/bin/npm', npm verb cli '--registry', npm verb cli 'http://www.exemple.com/repository/npm-group/', npm verb cli 'install', npm verb cli 'generator-exemple-flak-api', npm verb cli '--loglevel', npm verb cli 'verbose' npm verb cli ] npm info using npm@6.10.2 npm info using node@v12.8.1 npm verb npm-session 86bac6cdd6426873 npm timing stage:rollbackFailedOptional Completed in 1ms npm timing stage:runTopLevelLifecycles Completed in 131ms npm verb type system npm verb stack FetchError: request to http://www.exemple.com/repository/npm-group/generator-exemple-flak-api failed, reason: Parse Error: Content-Length can't be present with chunked encoding npm verb stack at ClientRequest. (/usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14) npm verb stack at ClientRequest.emit (events.js:203:13) npm verb stack at Socket.socketOnData (_http_client.js:456:9) npm verb stack at Socket.emit (events.js:203:13) npm verb stack at addChunk (_stream_readable.js:295:12) npm verb stack at readableAddChunk (_stream_readable.js:276:11) npm verb stack at Socket.Readable.push (_stream_readable.js:210:10) npm verb stack at TCP.onStreamRead (internal/stream_base_commons.js:166:17) npm verb cwd /tmp npm verb Linux 3.10.0-957.27.2.el7.x86_64 npm verb argv "/usr/bin/node" "/usr/bin/npm" "--registry" "http://www.exemple.com/repository/npm-group/" "install" "generator-exemple-flak-api" "--loglevel" "verbose" npm verb node v12.8.1 npm verb npm v6.10.2 npm ERR! code HPE_UNEXPECTED_CONTENT_LENGTH npm ERR! errno HPE_UNEXPECTED_CONTENT_LENGTH npm ERR! request to http://www.exemple.com/repository/npm-group/generator-exemple-flak-api failed, reason: Parse Error: Content-Length can't be present with chunked encoding npm verb exit [ 1, true ] npm timing npm Completed in 387ms

npm ERR! A complete log of this run can be found in: npm ERR! /home/vmuser/.npm/_logs/2019-08-30T14_56_28_661Z-debug.log

2019-08-30T14_56_28_661Z-debug.log

The error seems comming from the nexus-proxy because when I disable the nexus-proxy and directly access the nexus I don't get the error.

Is there a configuration parameter to avoid this error?

Thanks for your help. Reagrds, Renaud

varditn commented 5 years ago

Hi , have you tried the suggested solution here: https://github.com/travelaudience/nexus-proxy/issues/18 ?

RenaudDemarneffe commented 5 years ago

Hi, I tested the solution but it doesn't work.

marianocodes commented 4 years ago

I'm experiencing the same problem, @RenaudDemarneffe Did you find a workaround?

RenaudDemarneffe commented 4 years ago

Hi @mahcr, I have updated the order used to set the headers of the response but I don't know if it's the right solution. Here is the updated file: https://github.com/ipulses/nexus-proxy/blob/master/src/main/java/com/travelaudience/nexus/proxy/NexusHttpProxy.java

xpicio commented 4 years ago

@Tavardit I have the same problem with npm (I'm using Nexus 3.19.1, i did some tests with local docker image and the npm repository works with Nexus> = 3.18, so i think Nexus image is ok). Here the log of command npm addUser

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/xpicio/.nvm/versions/node/v12.13.1/bin/node',
1 verbose cli   '/Users/xpicio/.nvm/versions/node/v12.13.1/bin/npm',
1 verbose cli   'addUser'
1 verbose cli ]
2 info using npm@6.12.1
3 info using node@v12.13.1
4 verbose npm-session 9b6549067905557d
5 verbose web login before first POST
6 verbose adduser before first PUT {
6 verbose adduser   _id: 'org.couchdb.user:xpicio@gmail.com',
6 verbose adduser   name: 'xpicio@gmail.com',
6 verbose adduser   password: 'XXXXX',
6 verbose adduser   email: 'xpicio@gmail.com',
6 verbose adduser   type: 'user',
6 verbose adduser   roles: [],
6 verbose adduser   date: '2019-11-20T11:08:13.544Z'
6 verbose adduser }
7 verbose type system
8 verbose stack FetchError: request to https://repository.scmgroup.com/repository/mconnect-npm/-/user/org.couchdb.user:xpicio%40gmail.com failed, reason: Parse Error: Content-Length can't be present with chunked encoding
8 verbose stack     at ClientRequest.<anonymous> (/Users/xpicio/.nvm/versions/node/v12.13.1/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:68:14)
8 verbose stack     at ClientRequest.emit (events.js:210:5)
8 verbose stack     at TLSSocket.socketOnData (_http_client.js:463:9)
8 verbose stack     at TLSSocket.emit (events.js:210:5)
8 verbose stack     at addChunk (_stream_readable.js:309:12)
8 verbose stack     at readableAddChunk (_stream_readable.js:290:11)
8 verbose stack     at TLSSocket.Readable.push (_stream_readable.js:224:10)
8 verbose stack     at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23)
9 verbose cwd /Users/xpicio/Documents/Projects/scmgroup/epic-library
10 verbose Darwin 19.0.0
11 verbose argv "/Users/xpicio/.nvm/versions/node/v12.13.1/bin/node" "/Users/xpicio/.nvm/versions/node/v12.13.1/bin/npm" "addUser"
12 verbose node v12.13.1
13 verbose npm  v6.12.1
14 error code HPE_UNEXPECTED_CONTENT_LENGTH
15 error errno HPE_UNEXPECTED_CONTENT_LENGTH
16 error request to https://repository.scmgroup.com/repository/mconnect-npm/-/user/org.couchdb.user:xpicio%40gmail.com failed, reason: Parse Error: Content-Length can't be present with chunked encoding
17 verbose exit [ 1, true ]

reason: Parse Error: Content-Length can't be present with chunked encoding

Could you fix this issue? Thanks in advance

luigicaiffa commented 4 years ago

@TAvardit I have the same problem with PyPI.

I used twine for the upload and it works properly. But when I try to install the package using the command: pip install <pkg_name> --extra-index-url <repo_url>

the error appears: WARNING: Received response with both Content-Length and Transfer-Encoding set. This is expressly forbidden by RFC 7230 sec 3.3.2. Ignoring Content-Length and attempting to process response as Transfer-Encoding: chunked.

Gabology commented 4 years ago

Having the same issue here, any update to this?