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
Initially reported to Nuxt here - nuxt/nuxt#35374, there is a bug that causes HMR to hang forever in loading state.
On first edit, it reloads and everything seems to be normal. Then on second edit + file save - the dev server totally hangs forever. I have attached a screencast to easily see the problem.
Edit layers/common/server/api/user.ts and save it. Everything reloads as normal. ✅
Edit the user.ts file one more time and save it. The dev server now hangs forever ❌ 😔
With the help of AI, I was able to get a fix and added failing tests:
In Nitropack’s DevServer, during HMR it was routing requests to a stale worker while building=true, then killing that worker on reload — leaving SSR requests hung.
During Nitro HMR, getWorker() could still hand requests to an old dev worker while building=true, and dev:reload then killed that worker mid-SSR — so the browser reload never finished.
The patch closes workers as soon as a rebuild starts and makes getWorker() wait for a fresh worker instead of reusing a stale one during building, with a 120s safety cap.
Environment
Reproduction
https://stackblitz.com/github/martinszeltins/nuxt-hmr-hang-bug
Describe the bug
Initially reported to Nuxt here - nuxt/nuxt#35374, there is a bug that causes HMR to hang forever in loading state.
On first edit, it reloads and everything seems to be normal. Then on second edit + file save - the dev server totally hangs forever. I have attached a screencast to easily see the problem.
layers/common/server/api/user.tsand save it. Everything reloads as normal. ✅user.tsfile one more time and save it. The dev server now hangs forever ❌ 😔With the help of AI, I was able to get a fix and added failing tests:
Here is a repo with the patch applied that seems to fix the issue:
https://github.com/martinszeltins/nuxt-nitro-hang-patch-fix
pnpm-workspace.yaml:
patches/nitropack@2.13.4.patch:
HMR tests failing tests that show the hang bug:
martinszeltins#1
Patch that makes the tests pass:
Screencast:
Kazam_screencast_00153.mp4
Additional context
No response
Logs