next.js
26084997 - fix: wait for webpack HMR to complete before refreshing server components

Commit
126 days ago
fix: wait for webpack HMR to complete before refreshing server components During HMR, the dev server sends BUILT (triggering async module.hot.apply()) before SERVER_COMPONENT_CHANGES (triggering hmrRefresh()). Previously, hmrRefresh() fired immediately without waiting for the webpack update to finish, creating a race where __webpack_require__ could be called for modules that were temporarily absent from __webpack_modules__ during the swap. This was previously masked because the resulting TypeError was caught by React's error boundary, but webpack 5.104+ added an explicit module existence check that turns this into a hard "Cannot find module" error. Fix by awaiting the pendingHotUpdateWebpack promise before calling hmrRefresh(), ensuring all webpack modules are fully in place before the RSC response tries to reference them.
Author
Parents
Loading