Webpack-dev-server: SockJS crashes session

Created on 26 Apr 2016  路  10Comments  路  Source: webpack/webpack-dev-server

I am getting frequency crashes due to an apparent SockJS session timeout:

/home/tquetano/git/platform-js/node_modules/webpack-dev-server/node_modules/sockjs/lib/trans-websocket.js:157
      return this.session.close(3000, 'No response from heartbeat');
                         ^

TypeError: Cannot read property 'close' of null
    at WebSocketReceiver.heartbeat_timeout (/home/tquetano/git/platform-js/node_modules/webpack-dev-server/node_modules/sockjs/lib/trans-websocket.js:157:26)
    at null._onTimeout (/home/tquetano/git/platform-js/node_modules/webpack-dev-server/node_modules/sockjs/lib/trans-websocket.js:75:24)
    at Timer.listOnTimeout (timers.js:92:15)

npm ERR! Linux 4.4.0-18-generic
npm ERR! argv "/home/tquetano/.nvm/versions/node/v4.2.2/bin/node" "/home/tquetano/.nvm/versions/node/v4.2.2/bin/npm" "run" "dev"
npm ERR! node v4.2.2
npm ERR! npm  v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! [email protected] dev: `NODE_ENV=development ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev script 'NODE_ENV=development ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress'.
npm ERR! This is most likely a problem with the platform package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     NODE_ENV=development ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --progress
npm ERR! You can get their info via:
npm ERR!     npm owner ls platform
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/tquetano/git/platform-js/npm-debug.log

Is there a way to configure to increase the timeout, or at least check for the existence of the session object before attempting to use its close property? This is happening very frequently, in some cases in as little as a few minutes after very basic usage

Most helpful comment

@csaintc @byCedric btw, removing your node_modules directory and doing fresh npm install should fix the issue as well, as the new sockjs version 0.3.17 matches the semver ^0.3.15 specified in webpack-dev-server's package.js. If this doesn't help, you can manually npm install [email protected].

I suggest updating semver in dev-server's package.json only to enforce installation of the new sockjs version in all cases, e.g. behind a caching npm proxy.

All 10 comments

Had exact same issue after migrating to another machine.
In my case it was crashing right after the initial loading (which worked absolutely fine).
Setting higher values in config fixed it for me.

devServer: {
  watchOptions: {
    aggregateTimeout: 1000,
    poll: 1500
  }
}

Yeah no dice for me... it still crashes with regularity.

I'm seeing this crash really frequently as well. I'm using webpack-dev-server 1.14.1 and node 4.2.2 on Ubuntu 14.04 LTS (x86_64 2.16.0-70-generic). Setting the devServer options in my webpack config file didn't seem to make a difference.

I'm seeing this too, several times an hour (running client inside a VM); makes webpack-dev-server completely unusable.

Here are the related SockJS issues: https://github.com/sockjs/sockjs-node/issues/185 https://github.com/sockjs/sockjs-node/issues/197. They say it's fixed in sockjs-node v0.3.17.

Updating version of sockjs in package.json to ^0.3.17 should fix this.

Getting the same issue

Same problem over here...

@csaintc @byCedric btw, removing your node_modules directory and doing fresh npm install should fix the issue as well, as the new sockjs version 0.3.17 matches the semver ^0.3.15 specified in webpack-dev-server's package.js. If this doesn't help, you can manually npm install [email protected].

I suggest updating semver in dev-server's package.json only to enforce installation of the new sockjs version in all cases, e.g. behind a caching npm proxy.

I did update it just before lunch, and it didn't crash a single time until now! So I guess the new version worked like a charm! Thanks for the heads up @skozin

@tquetano-r7, do you still have this issue?

Nope, sorry I should have closed this a while ago.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hnqlvs picture hnqlvs  路  3Comments

nikirossi picture nikirossi  路  3Comments

piotrszaredko picture piotrszaredko  路  3Comments

eyakcn picture eyakcn  路  3Comments

uMaxmaxmaximus picture uMaxmaxmaximus  路  3Comments