webpack-dev-server v3.1.2 breaks hot reloading for my app with the following error in the browser:
only-dev-server.js:9
Uncaught TypeError: Cannot read property 'indexOf' of undefined
at upToDate (only-dev-server.js:9)
at EventEmitter.<anonymous> (only-dev-server.js:87)
at EventEmitter.push../node_modules/events/events.js.EventEmitter.emit (events.js:81)
at reloadApp (client?fd53:226)
at Object.ok (client?fd53:139)
at SockJS.onmessage (socket.js:41)
at SockJS.EventTarget.dispatchEvent (eventtarget.js:51)
at main.js:274
at Array.forEach (<anonymous>)
at SockJS._transportMessage (main.js:272)
The code at only-dev-server.js:9 looks like this
if (module.hot) {
var lastHash;
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
the crash at lastHash being undefined when calling indexOf would lead me to believe that
hotEmitter.on("webpackHotUpdate", function(currentHash) {
was never called.
Switching back to 3.1.1 fixes the problem.
My setup uses splitChunks enabled, and the error message would lead me to believe that the hash for the updated chunk could not be found?
splitChunks: {
name: true,
chunks: "all",
},
A minimal proof-of-concept can be found here:
https://github.com/bes/webpack-dev-server-3.1.2-bug-hot-reload
Hot reload to work
Hot reload crashes with the above stack trace.
Use the POC linked above
The only patches between 3.1.1 and 3.1.2 are
+1
Facing same problem, with the same setup but on Windows 10.
+1.
My error msg is 'lastHash is undefined'
+1.
"webpack-dev-server": "^3.1.1"
when I upgrade webpack-dev-server from "^3.1.1" to "^3.1.2", I encountered the same problem, how to fixed it?
@happystory I just rollback "webpack-dev-server": "3.1.0", is work and waitting bug fixed.
+1
"webpack-dev-server": "^3.1.2"
+1 with v3.1.2
dev-server.js:9 Uncaught TypeError: Cannot read property 'indexOf' of undefined
at upToDate (webpack:///(:/webpack)/hot/dev-server.js?:9:19)
Thanks for your clear report. It should be fixed with [email protected].
Most helpful comment
Thanks for your clear report. It should be fixed with
[email protected].