create-react-app trying to get compression lib over HTTP instead of HTTPS - failing behind proxy

Created on 7 Jun 2018  路  6Comments  路  Source: facebook/create-react-app

Is this a bug report?

Yes

Did you try recovering your dependencies?

$ npm --version
6.1.0
$ yarn --version
1.7.0

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

Environment:
OS: Windows 7
Node: 10.4.0
Yarn: 1.7.0

Steps to Reproduce

  1. create-react-app failing behind our corporate proxy. Yarn seems to use HTTP rather than HTTPS to get the 'compression' library - my company uses 'Forcepoint' and it is blocking HTTP traffic to npmjs. Not sure why this one library is not being fetched via HTTPS.

Note the verbose log output from create-react-app, this happens consistently. Everything up until the compression library works as its getting fetched via HTTPS:

verbose 25.081 Request "https://registry.npmjs.org/object-copy" finished with status code 200.
verbose 25.086 Performing "GET" request to "https://registry.npmjs.org/copy-descriptor".
verbose 25.243 Request "https://registry.npmjs.org/copy-descriptor" finished with status code 200.
[2/4] Fetching packages...
verbose 25.502 Performing "GET" request to "http://registry.npmjs.org/compression/-/compression-1.7.2.tgz".
verbose 25.554 Error: http://registry.npmjs.org/compression/-/compression-1.7.2.tgz: Invalid tar header. Maybe the tar is c
orrupted or it needs to be gunzipped?

at Object.module.exports.exports.decode (C:\Users\smcgillAppData\Roaming\npm\node_modulesyarn\lib\cli.js:77578:43)
at Extract.onheader (C:\Users\smcgillAppData\Roaming\npm\node_modulesyarn\lib\cli.js:146111:39)

Expected Behavior

Create a new react app

Actual Behavior

Fails consistently trying to download compression library due to our website filtering infrastructure blocking HTTP traffic to npmjs

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Most helpful comment

@rodoabad I was having this issue as well so I looked through the yarn issues and found issue #746. Someone had said they disabled their antivirus which solved their problem with socket hang ups. I was running Malwarebytes and upon quitting it, I no longer had this error.

All 6 comments

Can reproduce, have yet to find a fix. Works fine with NPM.

Environment

  • Windows 10 1803 17134.112 x64
  • Node 8.11.3 or 10.4.1
  • Yarn 1.6.0 or 1.7.0 or 1.9.0-20180614.1132
  • Network: Wired, No Proxy, 20ms Ping, 94Mbps Download, 11Mbps Upload, 1.1.1.1 DNS

Attempted Fixes

  • Reinstalling Yarn and Node (multiple versions)
  • Admin Terminal (PowerShell)
  • Clearing Yarn and NPM Cache
  • Reinstalling (globally) create-react-app
  • Clearing DNS Cache
  • Restarting PC

Verbose Output

...
verbose 65.602 Performing "GET" request to "https://registry.yarnpkg.com/react/-/react-16.4.1.tgz".
verbose 65.603 Performing "GET" request to "https://registry.yarnpkg.com/react-dom/-/react-dom-16.4.1.tgz".
verbose 65.613 Performing "GET" request to "https://registry.yarnpkg.com/react-scripts-ts/-/react-scripts-ts-2.16.0.tgz".
info There appears to be trouble with your network connection. Retrying...
verbose 78.42 Performing "GET" request to "http://registry.npmjs.org/compression/-/compression-1.7.2.tgz".
info There appears to be trouble with your network connection. Retrying...
verbose 96.48 Performing "GET" request to "http://registry.npmjs.org/compression/-/compression-1.7.2.tgz".
verbose 112.552 Error: http://registry.npmjs.org/compression/-/compression-1.7.2.tgz: socket hang up
    at createHangUpError (_http_client.js:313:15)
    at Socket.socketOnEnd (_http_client.js:416:23)
    at Socket.emit (events.js:187:15)
    at endReadableNT (_stream_readable.js:1081:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
error An unexpected error occurred: "http://registry.npmjs.org/compression/-/compression-1.7.2.tgz: socket hang up".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\Ethan\\Documents\\Elite\\Frontend\\web\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts-ts --cwd C:\Users\Ethan\Documents\Elite\Frontend\web --verbose has failed.

Deleting generated file... package.json
Deleting generated file... yarn-error.log
Done.

I don't think this is a create-react-app issue. More like yarn.

@rodoabad I was having this issue as well so I looked through the yarn issues and found issue #746. Someone had said they disabled their antivirus which solved their problem with socket hang ups. I was running Malwarebytes and upon quitting it, I no longer had this error.

@shleycarter Thank you, this seems to have been my problem as well. Have you figured a solution on what to add to Malwarebytes' Exclusions List, rather than disabling protection as a whole?

EDIT: Latest Malwarebytes update fixes this issue!

For me turning off Windows Defender worked.

Turning off windows defender also worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stopachka picture stopachka  路  3Comments

AlexeyRyashencev picture AlexeyRyashencev  路  3Comments

fson picture fson  路  3Comments

DaveLindberg picture DaveLindberg  路  3Comments

oltsa picture oltsa  路  3Comments