Webpack-dev-server: 3.1.2 breaks hot reload for my setup

Created on 7 Apr 2018  路  9Comments  路  Source: webpack/webpack-dev-server

  • Operating System: macOS
  • Node Version: 9.11.1
  • NPM Version: 5.6.0
  • webpack Version: 4.5.0
  • webpack-dev-server Version: 3.1.2
  • [x] This is a bug
  • [ ] This is a modification request

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.

Code

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

Expected Behavior

Hot reload to work

Actual Behavior

Hot reload crashes with the above stack trace.

For Bugs; How can we reproduce the behavior?

Use the POC linked above

For Features; What is the motivation and/or use-case for the feature?

Most helpful comment

Thanks for your clear report. It should be fixed with [email protected].

All 9 comments

+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].

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StephanBijzitter picture StephanBijzitter  路  3Comments

mrdulin picture mrdulin  路  3Comments

MJ111 picture MJ111  路  3Comments

eyakcn picture eyakcn  路  3Comments

da2018 picture da2018  路  3Comments