Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack 5 - hmr check api no longer returns updated modules #12408

Closed
lukeapage opened this issue Jan 12, 2021 · 11 comments
Closed

webpack 5 - hmr check api no longer returns updated modules #12408

lukeapage opened this issue Jan 12, 2021 · 11 comments

Comments

@lukeapage
Copy link
Contributor

Bug report

webpack-contrib/webpack-hot-middleware#390

I've been investigating the cause.

as per the documentation https://webpack.js.org/api/hot-module-replacement/#check
it expects check to yield an array of updated modules. It uses this to compare to the updated modules in order to decide whether to reload.

when I debug I see:

https://github.com/webpack/webpack/blob/master/lib/hmr/HotModuleReplacement.runtime.js#L257
check doesn't add any modules, it passes the array to the runtime to update.

https://github.com/webpack/webpack/blob/master/lib/hmr/JavascriptHotModuleReplacement.runtime.js#L413
The runtime doesn't add any modules, but it passes the array on to the loader

"function loadUpdateChunk(chunkId) {",

The loader doesn't accept the second argument so it doesn't add any modules to the array

It looks like a bug because the documentation wasn't changed and the code still references the updatedModules array.

Seems it was introduced in webpack 5 alpha. 0 here:
9d91861#diff-99b22d1932803b7795bbe843d01cdf63d32e52a247610bfd9cffb95170227cc6

it seems that the node/ version had the updated module id's, but the web version does not.

Other relevant information:
webpack version: 5.3.1
Node.js version: 12
Operating System: windows 10
Additional tools:

@alexander-akait
Copy link
Member

/cc @sokra

@sokra sokra added bug and removed question labels Jan 12, 2021
@samhuk
Copy link

samhuk commented Feb 25, 2021

Just an FYI: I created an issue with webpack-hot-middleware that details an eventual side-effect of this: webpack-contrib/webpack-hot-middleware#398. I believe that it's the exact same thing going on as in your linked issue (webpack-contrib/webpack-hot-middleware#390)

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@alexander-akait
Copy link
Member

bump

@rocalvo-meli
Copy link

Hi! I'm facing the same problem, there is any update ?

@otakustay
Copy link

otakustay commented Aug 5, 2021

Facing the same issue, by stepping into it a little further, I find this code in node_modules/webpack/lib/hmr/JavascriptHotModuleReplacement.runtime.js at around line 439:

chunkIds.forEach(function (chunkId) {
	if (
		$hasOwnProperty$($installedChunks$, chunkId) &&
		$installedChunks$[chunkId] !== undefined
	) {
		// HERE
		promises.push($loadUpdateChunk$(chunkId, updatedModulesList));
		currentUpdateChunks[chunkId] = true;
	}
});

This calls loadUpdateChunk with 2 arguments, however inside node_modules/webpack/lib/web/JsonpChunkLoadingRuntimeModule.js around line 273, loadUpdateChunk is defined as:

? Template.asString([
		"var currentUpdatedModulesList;",
		"var waitingUpdateResolves = {};",
		// HERE
		"function loadUpdateChunk(chunkId) {",
		Template.indent([
			`return new Promise(${runtimeTemplate.basicFunction(
				"resolve, reject",
				[

It only defines one parameter, it never pushes any entry into updatedModulesList array, causing hot.check fails to report updated modules.

But weirdly, this long lived issue only affects us in recent several days when we deleted our lock file and have a fresh install, not sure if there is any other root causes

@TrejGun
Copy link
Contributor

TrejGun commented Aug 21, 2021

bump

@Herz3h
Copy link

Herz3h commented Nov 30, 2021

any news on this ?

@tangtangtangtangtang
Copy link

is there any progress?

@sokra
Copy link
Member

sokra commented Jan 11, 2022

Send a PR

@vankop
Copy link
Member

vankop commented Apr 13, 2022

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests