You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: HMR re-executes a module before the new async chunk its imports moved to is loaded ("Cannot read properties of undefined (reading 'call')") #16288
A module in a loaded async chunk self-accepts. An edit gives it its first node_modules import. splitChunks puts the package in a new async chunk (a sibling of the module's chunk). The hot update re-executes the module before anything loads that chunk:
TypeError: Cannot read properties of undefined (reading 'call')
at __webpack_require__ (http://127.0.0.1:3618/static/js/index.js:53:29)
at fn (http://127.0.0.1:3618/static/js/index.js:232:10)
at ./src/lazy.js (http://127.0.0.1:3618/src_lazy_js.a9f1d732bcbbc318.hot-update.js:5:44)
The page keeps the old code and does not reload. The new vendors chunk is only fetched afterwards.
// src/lazy.js, after the edit (the lodash import is new)import_from'lodash'document.getElementById('out').textContent='lazy-v1 '+typeof_.chunkif(import.meta.webpackHot){import.meta.webpackHot.accept()}
Fails with Rsbuild's default splitChunks and with splitChunks: { preset: 'none', chunks: 'async' }, with dev.lazyCompilation on or off.
Works when cacheGroups: { default: false, defaultVendors: false } (lodash stays in src_lazy_js, no new chunk).
Expected: the page shows lazy-v1 function: the new chunk is loaded before the module re-executes. At minimum, the error should lead to a full reload.
Related: #11324 and #11922 (same mechanism). They were resolved with reloadOnRuntimeErrors in @rspack/plugin-react-refresh, but that matches error.message.startsWith('RuntimeError: factory is undefined') (2.0.2), and this case throws the bare TypeError above, so it does not reload either. webpack/webpack#19494 fixed the analogous case for new initial chunks by loading them during the update.
Suspected fix (untested): before re-executing outdated modules, load the not-yet-installed chunks of the updated chunks' chunk groups (e.g. listed in the hot-update manifest), as __webpack_require__.e would for a fresh import().
Activity