Yarn: [bug] socket hang up

Created on 11 Oct 2016  Â·  39Comments  Â·  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?
Bug

What is the current behavior?
When running yarn with existing (and correct) package.json and empty node_modules I get socket hang up error on a X package. Next time I run yarn I get the same error, but for Y package.

Example output:

$ yarn                                                                                                                                                                   
yarn install v0.15.1
info No lockfile found.
[1/4] Resolving packages...
error https://registry.yarnpkg.com/semver: socket hang up
    at createHangUpError (_http_client.js:252:15)
    at TLSSocket.socketCloseListener (_http_client.js:284:23)
    at emitOne (events.js:101:20)
    at TLSSocket.emit (events.js:188:7)
    at TCP._handle.close [as _onclose] (net.js:493:12)

If the current behavior is a bug, please provide the steps to reproduce.
Hard to think of steps to reproduce the issue. Below are my dependencies:

  "dependencies": {
    "axios": "^0.14.0",
    "babel-polyfill": "^6.13.0",
    "babel-runtime": "^6.11.6",
    "classnames": "^2.2.5",
    "dom-helpers": "^2.4.0",
    "elemental": "^0.6.1",
    "flexboxgrid": "^6.3.1",
    "get-env": "^0.5.1",
    "icheck": "^1.0.2",
    "immutable": "^3.8.1",
    "js-combinatorics": "^0.5.2",
    "localforage": "^1.4.2",
    "lodash": "^4.15.0",
    "moment": "^2.15.1",
    "moment-duration-format": "^1.3.0",
    "normalizr": "^2.2.1",
    "qs": "^6.2.1",
    "ramda": "^0.22.1",
    "rc-time-picker": "^2.0.2",
    "react": "^15.3.2",
    "react-addons-css-transition-group": "^15.3.2",
    "react-addons-shallow-compare": "^15.3.2",
    "react-addons-transition-group": "^15.3.2",
    "react-dates": "^3.1.1",
    "react-dom": "^15.3.2",
    "react-flexbox-grid": "^0.10.2",
    "react-highlight-words": "^0.4.1",
    "react-icheck": "^0.3.5",
    "react-popover": "^0.4.4",
    "react-redux": "^5.0.0-beta.3",
    "react-responsive": "^1.1.5",
    "react-router": "^2.7.0",
    "react-router-redux": "^4.0.5",
    "react-select": "^1.0.0-rc.1",
    "react-selectize": "^2.0.3",
    "react-skylight": "^0.4.1",
    "react-smooth-collapse": "^1.1.0",
    "react-tabs": "^0.8.0",
    "react-virtualized": "^8.0.11",
    "reactstrap": "^3.4.0",
    "recharts": "^0.14.1",
    "redux": "^3.6.0",
    "redux-actions": "^0.12.0",
    "redux-form": "^6.1.0",
    "redux-logger": "^2.6.1",
    "redux-logic": "^0.9.3",
    "redux-thunk": "^2.1.0",
    "reselect": "^2.5.4",
    "rxjs": "^5.0.0-beta.12",
    "tether": "^1.3.7",
    "uuid-js": "^0.7.5"
  },
  "devDependencies": {
    "autoprefixer": "^6.4.0",
    "babel-core": "^6.14.0",
    "babel-eslint": "^6.1.2",
    "babel-loader": "^6.2.5",
    "babel-plugin-transform-class-properties": "^6.11.5",
    "babel-plugin-transform-object-rest-spread": "^6.8.0",
    "babel-plugin-transform-runtime": "^6.12.0",
    "babel-preset-es2015": "^6.14.0",
    "babel-preset-es2016": "^6.11.3",
    "babel-preset-es2017": "^6.14.0",
    "babel-preset-react": "^6.11.1",
    "css-loader": "^0.24.0",
    "eslint": "^3.4.0",
    "eslint-config-airbnb-base": "^5.0.3",
    "eslint-import-resolver-webpack": "^0.5.1",
    "eslint-plugin-import": "^1.14.0",
    "eslint-plugin-jsx-a11y": "^2.2.0",
    "eslint-plugin-lodash-fp": "^2.0.1",
    "eslint-plugin-react": "^6.2.0",
    "extract-text-webpack-plugin": "^2.0.0-beta.4",
    "file-loader": "^0.9.0",
    "handlebars": "^4.0.5",
    "handlebars-loader": "^1.3.0",
    "html-webpack-plugin": "^2.22.0",
    "node-sass": "^3.10.1",
    "postcss-loader": "^0.11.1",
    "postcss-modules-values": "^1.2.2",
    "postcss-scss": "^0.2.1",
    "postcss-strip-inline-comments": "^0.1.5",
    "precss": "^1.4.0",
    "react-immutable-proptypes": "^2.1.0",
    "react-moment-proptypes": "^1.2.0",
    "sass-loader": "^4.0.2",
    "source-map-loader": "^0.1.5",
    "style-loader": "^0.13.1",
    "stylelint": "^7.2.0",
    "stylelint-config-standard": "^13.0.0",
    "stylelint-webpack-plugin": "^0.3.1",
    "url-loader": "^0.5.7",
    "webpack": "2.1.0-beta.21",
    "webpack-dashboard": "^0.1.8",
    "webpack-dev-server": "2.1.0-beta.1"
  }

What is the expected behavior?
Yarn should install all packages, npm works just fine with my current setup.

Please mention your node.js, yarn and operating system version.
yarn: 0.15.1
OS: Linux 4.7.6-1
node: v6.6.0

I suppose this may be the problem with servers being overloaded but I'm posting this issue in case there's something else and this is in fact some bug.

triaged

Most helpful comment

I was able to solve this problem by disabling my antivirus (Malwarebytes in my case).

All 39 comments

OK, it seems that it's not yarn specific problem. I've just run npm install and it also failed (where it was ok very recently). The npm error log is more verbose though:

> [email protected] install /home/user/projects/p1/node_modules/node-sass
> node scripts/install.js

Start downloading binary at https://github.com/sass/node-sass/releases/download/v3.10.1/linux-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v3.10.1/linux-x64-48_binding.node": ode:

ESOCKETTIMEDOUT

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g.

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> [email protected] postinstall /home/user/projects/p1/node_modules/node-sass
> node scripts/build.js

"/home/user/projects/p1/node_modules/node-sass/vendor/linux-x64-48/binding.node" exists.
 testing binary.
[1]    23887 bus error (core dumped)  npm install

I am getting the socket hang up issue also, but do not get the issue when running npm install

From my package.json:

  "dependencies": {
    "pg": "^6.1.0"
  },
  "devDependencies": {
    "jasmine": "^2.5.2",
    "jasmine-spec-reporter": "^2.7.0",
    "mock-require": "^1.3.0"
  }
λ yarn install
yarn install v0.15.1
info No lockfile found.
warning [email protected]: No license field
[1/4] Resolving packages...
error socket hang up
    at TLSSocket.onHangUp (_tls_wrap.js:1049:19)
    at TLSSocket.g (events.js:260:16)
    at emitNone (events.js:72:20)
    at TLSSocket.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

One thing I do know is that our corporate firewall is currently blocking yarnpkg.com and should hopefully be cleared up tomorrow some time. Not sure if this is an issue.

This is also happening to me. But like for @jimpoulakos , npm i is working fine

Windows 10, 512kbps... I can't finish any install. Lots of (random) socket hang ups. NPM works properly most of the time

Example:

yarn add v0.15.1
info No lockfile found.
[1/4] Resolving packages...
error https://registry.yarnpkg.com/babel-preset-es2015-node: socket hang up
at createHangUpError (_http_client.js:252:15)
at TLSSocket.socketOnEnd (_http_client.js:344:23)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

I'm reopening this issue, since other people seem to be affected by it.

Not sure if this issue has been fixed but I'm also getting the same issue when doing yarn with empty node_modules directory. I have tested it with npm install and it works correctly though without any problem.

But yarn gives this error and halts:

 ➜ yarn
yarn install v0.15.1
info No lockfile found.
[1/4] Resolving packages...
warning grunt > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning grunt > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning grunt-modernizr > customizr > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning wiredep > glob > [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning grunt-modernizr > customizr > [email protected]: use [cross-spawn](https://github.com/IndigoUnited/node-cross-spawn) or [cross-spawn-async](https://github.com/IndigoUnited/node-cross-spawn-async) instead.
warning generator-jhipster > yo > [email protected]: cross-spawn no longer requires a build toolchain, use it instead!
warning generator-jhipster > yeoman-generator > cross-spawn > [email protected]: cross-spawn no longer requires a build toolchain, use it instead!
warning grunt > glob > [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
warning wiredep > bower-config > [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
warning protractor > request > [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
warning yo > fullname > [email protected]: this package has been reintegrated into npm and is now out of date with respect to npm
error https://registry.yarnpkg.com/binary-extensions: socket hang up
    at createHangUpError (_http_client.js:250:15)
    at TLSSocket.socketCloseListener (_http_client.js:282:23)
    at emitOne (events.js:101:20)
    at TLSSocket.emit (events.js:188:7)
    at TCP._handle.close [as _onclose] (net.js:485:12)
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

same problem here "socket hang up"

Same problem about "socket hang up"
I set a http_proxy.

I am getting the socket hang up issue too

it's happening to me

Same problem here.

Same problem. The error appears randomly at different packages. Here is a sample:

error https://registry.yarnpkg.com/postcss-modules-extract-imports: socket hang up
at createHangUpError (_http_client.js:252:15)
at TLSSocket.socketCloseListener (_http_client.js:284:23)
at emitOne (events.js:101:20)
at TLSSocket.emit (events.js:188:7)
at TCP._handle.close as _onclose
info Visit http://yarnpkg.com/en/docs/cli/install for documentation about this command.

It doesn't matter if a node_modules directory exist or not. npm i works fine. If I didn't find this thread and due to the randomness of the error, I would have thrown the blame on my horrible ISP. However, surely not everyone here has a stone age internet connection!

Same here.
I think it is related to Internet speed.
I'm not sure how Yarn works internally but I believe it fetches more than one package at a time with no limit (correct me if I'm wrong), so with weak/slow internet connections it produces many random socket hang ups and timeouts.
I tried to install angular-cli for days and couldn't succeed but with npm it installs with no problem.
It I am right, there should be a way to limit concurrent connections.

@masihyeganeh I think you are right. I just came home where I have regular internet connection and yarn works as expected (whereas when I had this error, I was on unstable mobile connection). Also agree, that it would be good to have the feature to limit opened sockets.

Same problem here.

I think this is one of the major issues as I couldn't start working on a existing project using yarn after I did rm -rf node_modules/ and tried yarn, as the installation wouldn't just complete. So, I have to fallback to npm install anyway to make it work.
However, this works in the projects with only few dependencies. But for the projects with large number of dependencies it fails with this socket hang up error.

Same problem here.

I think it is related to Internet speed.

I can confirm this. At home I only have 2Mbit/s and it does not work there. At work I have a decently fast Internet connection and I don't get any errors.

I agree, bandwidth is the problem. After 5 attempts I moved closer to the router and it is working

@masihyeganeh
@michel-kraemer
I agree.
It's network speed problem.

Same problem here.

It seems to be fixed in 0.16.0. Can anyone confirm this?

That's hard to say of course @michel-kraemer. I don't think anyone has consistently reproduced it.
I can say I'm seeing warning There appears to be trouble with your network connection. Retrying... haven't seen that before and I have seen the socket hangup on this network.
However now I'm getting an ETIMEDOUT error which is perhaps related. I'll create a new issue

I reproduced the ETIMEDOUT 3 times, then the fourth time it worked. The error in yarn-error.log is:

Trace:
Error: read ETIMEDOUT
at exports._errnoException (util.js:1026:11)
at TLSWrap.onread (net.js:569:26)
Would you like a new issue for this or is this still considered the same problem?

Fast.com shows 20 Mbps internet.
Simple ping test:
--- google.com ping statistics ---
32 packets transmitted, 32 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 4.681/10.677/44.197/11.293 ms

With v0.16.0 now I get:

[2/4] Fetching packages...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
error An unexpected error occured, please open a bug report with the information provided in "*yarn-error.log".

and yarn-error.log contains:

Trace:
Error: read ECONNRESET
at exports._errnoException (util.js:1036:11)
at TLSWrap.onread (net.js:564:26)

That's exactly what I just described @jromero2k.

What I was trying to say in the comment right above yours @george3447 is please use github's reactions feature. Maintainers of this repo will likely be drowning in messages to go through as is 😉 . Also we won't all get notified of your +1's or duplicate messages.

yarn v0.16.0
node v6.9.1
macOS v10.12

warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
...

however, npm works fine.

Yarn connects to wholly different servers though so npm working where Yarn doesn't that might just be a bad connection to the Yarn proxy repo. Still that shouldn't cause exceptions.

[1/4] Resolving packages...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
warning There appears to be trouble with your network connection. Retrying...
error An unexpected error occured, please open a bug report with the information provided in "/home/kelvin/workspace/nodejs/Mean-Blog/server/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

@bsed Why not use githubs' reactions feature?

Yep. Same problem here. But when i checkouted another network, It become ok

@bestander for what I understand we can close this in favor of more specific issues.

I was able to solve this problem by disabling my antivirus (Malwarebytes in my case).

Like @shleycarter, I also solved by disabling Malwarebytes

Indeed Malwarebytes was the culprit in my case as well. For future reference, I was trying to install JHipster when it happened (yarn global add generator-jhipster).

Any news on this ???

Running on ubuntu app in Windows 10, trying to compile angular.

Yarn version:
1.12.3

Node version:
10.14.2

Platform:
linux x64

Trace:
Error: https://registry.yarnpkg.com/bower/-/bower-1.8.2.tgz: ESOCKETTIMEDOUT
at ClientRequest. (/mnt/c/Program Files (x86)/Yarn/lib/cli.js:129645:19)
at Object.onceWrapper (events.js:273:13)
at ClientRequest.emit (events.js:182:13)
at TLSSocket.emitRequestTimeout (_http_client.js:662:40)
at Object.onceWrapper (events.js:273:13)
at TLSSocket.emit (events.js:182:13)
at TLSSocket.Socket._onTimeout (net.js:453:8)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)

Any working solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MunifTanjim picture MunifTanjim  Â·  3Comments

sebmck picture sebmck  Â·  3Comments

AzGoalie picture AzGoalie  Â·  3Comments

baptistelebail picture baptistelebail  Â·  3Comments

davidmaxwaterman picture davidmaxwaterman  Â·  3Comments