question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack 5 HMR plugin error in runtime.[hash].hot-update.js

See original GitHub issue

Bug report

What is the current behavior? i am not sure whether this is webpack-dev-server issue or webpack or something else, however after 1st hot reload happens there is a constant error:

jsonp chunk loading:103 Uncaught TypeError: Cannot read property 'push' of undefined
    at self.webpackHotUpdatePACKAGEJSONNAME (jsonp chunk loading:103)
self["webpackHotUpdatePACKAGEJSONNAME"] = (chunkId, moreModules, runtime) => {
	for(var moduleId in moreModules) {
		if(__webpack_require__.o(moreModules, moduleId)) {
			currentUpdate[moduleId] = moreModules[moduleId];
			if(currentUpdatedModulesList) currentUpdatedModulesList.push(moduleId);
		}
	}
	if(runtime) currentUpdateRuntime.push(runtime); // error happens here
	if(waitingUpdateResolves[chunkId]) {
		waitingUpdateResolves[chunkId]();
		waitingUpdateResolves[chunkId] = undefined;
	}
};

If the current behavior is a bug, please provide the steps to reproduce.

launch dev-server with hot:true

What is the expected behavior? does not happen in webpack@4 i think that the issue is that this variable currentUpdateRuntime is accessed before it is initialized in: __webpack_require__.hmrI.jsonp or __webpack_require__.hmrC.jsonp

Other relevant information: webpack version: 5.1.0 Node.js version: v12.18.0 Operating System: Windows 10 Additional tools: webpack-devs-server@latest

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
birdofpreyrucommented, Oct 23, 2020

@evilebottnawi I figured it out. It happens if any XXX.hot-update.js is by mistake loaded into the frontend as a standalone script. Thus not a Webpack bug, but detecting it automatically and throwing a clear error message may be a nice feature. The mistake is easy to do, if somebody takes chunk names from webpack stats and injects them all as <script> into html (oiginally there is no xxx.hot-upload.js chunks, and when they appear it is difficult to find out the problem from an obscure error message about a crush inside Webpack).

2reactions
vjprcommented, Apr 14, 2022

I had the same issue when using Module Federation. If I remove the federated import (import('MyModule/Button')), then everything works fine. Adding the federated import and things break.

I am using a proxy to avoid CORS issues, so that localhost:3000 goes to my host app, and localhost:3000/federation/MyModule redirects to my other app.

When the websocket message arrives, it inits currentUpdateRuntime = [].

I think the issue is that the webpack/runtime/jsonp chunk loading (self.webpackHotUpdate) is being loaded a second time when I import my other app. In the dev tools, I can see that it’s being run from the other app when it errors. So I suspect it’s re-initing var currentUpdateRuntime;.

I guess its an issue with my entry point from my other app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack's Hot Module Replacement Feature Explained
The manifest contains a compilation hash and a list of all modules. Webpack will inject the HMR runtime into the generated bundle.js file ......
Read more >
Webpack-dev-server HMR not working with multiple entry ...
It seems like HMR has stopped working in my browser. Webpack is running and bundling it correctly! Any ideas? Thanks so far and...
Read more >
Webpack & The Hot Module Replacement | by rajaraodv
1. File Changed. Webpack along with HMR plugin generates a manifest file “<previousHash>.hot-update.json” and the update file “< ...
Read more >
Hot Module Replacement
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an ... Instantly update the browser when modifications are made to CSS/JS in...
Read more >
Hot Module Replacement
Starting from webpack 5, there's an alternative to module.hot . import.meta. ... the HMR interface notified the client portion of the code of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found