webpack-dev-server: TypeError: Cannot read property 'headers' of null at Server.socket.on (***/node_modules/webpack-dev-server/lib/servers/SockJSServer.js:68:32)
- Operating System: Windows 10
- Node Version: 12.8.1
- NPM Version: 6.10.3
- webpack Version: 4.39.2
- webpack-dev-server Version: since 3.5.0
- Browser: Chrome 76
- This is a bug
- This is a modification request
Expected Behavior
connection should not be null
Actual Behavior
TypeError: Cannot read property 'headers' of null at Server.socket.on (***/node_modules/webpack-dev-server/lib/servers/SockJSServer.js:68:32)
For Bugs; How can we reproduce the behavior?
This bug is difficult to reproduce. It happens occasionally.
line 67 should become
if (connection) {
f(connection, connection.headers)
}
For Features; What is the motivation and/or use-case for the feature?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 27 (5 by maintainers)
什么时候可以发布新的版本啊,,我要被这个问题搞死了,或者有没有什么其他的解决方法啊,一直在等新的版本出来
@Loonride i am thinking we should mark this as bug 😞
ok,我对这个不太懂,我现在是降低到3.7.0的版本了,暂时没有问题,而且具体没有研究过vue-cli3初始化的项目为什么package.json中的webpack是一个,,而不是分开的
The fix is released! Seems to be working for me so far, give it few days though…
npm update/yarn upgrade(hardcore:rm -r node_modules,rm -r package-lock.json/rm -r yarn.lockandnpm i/yarn install)Please read how to use package manager
@cereallarceny try adding the following in your webpack.config.js:
devServer: { contentBase: path.join(__dirname, 'dist'), compress: true, port: 3000 },I was having the same issue and this seemed to resolve it.
stumbled upon this issue as this actually occurs randomly for me when using
ng serveI see this issue intermittently when running an Angular app from a VS Code terminal. If I close VS Code and run it from a normal cli, I don’t seem to ever see it…
We’ve been running into this issue as well. It’s generally very intermittent, but I was able to reproduce it consistently by maxing out the cpu/memory utilization of the machine our app is running on (using a prime95 torture test), then navigating to the app. It only appears to occur when navigating directly to a url, or when refreshing the page.
Checking the console output in chrome shows the following errors:
It’s also worth mentioning that adding either of the following two bits to our webpack.config.js file resolves the issue if you do what I said above; however, we’re still seeing the failure occur in our linux docker containers in CircleCI. Those settings are:
I don’t know what you mean by this. There’s no such thing as an npm package at
webpack/webpack-dev-serverDoes anyone have any further information on the release schedule to resolve this?
This has been fixed in their master branch, but not yet released. I too would like a release soon, as it definitely impacts our automation, but in the meantime you can get the fix by pointing your package manager to their master branch. In NPM, that would mean changing the package.json reference to: “webpack-dev-server”: “webpack/webpack-dev-server#master”.
Hopefully this helps =)