`nuxt dev` reload never finishes when a Nuxt `close` hook doesn't settle
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, nuxt, typescript
Research direction
Start in packages/nuxt-cli/src/dev/utils.ts at #load() and close(), then read the shutdown budget in packages/nuxt-cli/src/dev/pool.ts and its closeFork logic. Check existing dev reload tests and add coverage for a Nuxt close hook that never settles. Done means reload proceeds after the shutdown deadline, reports the unfinished hooks, and the test passes.
Written by the indexing model from the issue text.
Description
Environment
@nuxt/cli4.0.3 (same code onmain, 7d4dec6)nuxt4.6.4,nitropack2.13.6,vite8.3.6- Node 24.22.2, Linux x64
Reproduction
https://github.com/mttzzz/nuxt-reload-close-hook-hang
The app has one local module:
// modules/hang-on-close.ts
import { defineNuxtModule } from 'nuxt/kit'
export default defineNuxtModule({
meta: { name: 'hang-on-close' },
setup(_options, nuxt) {
nuxt.hook('close', () => new Promise<void>(() => {}))
},
})
npm i && npx nuxt dev, the page showsmarker: one- change
marker: 'one'to'two'innuxt.config.ts
Describe the bug
After step 2 the page switches to the loading screen (503) and stays there (I waited 80 s), the reload is never reported as done. Saving nuxt.config.ts again does nothing, since the config watcher is closed before the reload and only re-armed after it. Ctrl-C still exits right away, so restarting nuxt dev is the only way out.
Without the module the same edit reloads in about 1 s. The same kind of hook in a Nitro plugin (nitroApp.hooks.hook('close', () => new Promise(() => {}))) only delays the reload by about 5 s: nitropack terminates the dev worker after NITRO_SHUTDOWN_TIMEOUT, and the reload goes on.
This came up in #1328, where @danielroe asked for a separate issue.
Cause
An in-place reload (a nuxt.config change, removed build output, nuxt.callHook('restart') from a module) goes through #load(), which awaits close(), and close() awaits this.#currentNuxt.close() with no deadline:
nuxt.close() calls the close hooks one after another, so the hooks registered after the module (Nitro's, Vite's, the builder watchers) are never called either.
Shutting the fork down already has a budget: closeFork waits DEV_SHUTDOWN_TIMEOUT_MS (10 s), then sends SIGTERM and SIGKILL:
The reload could get the same budget: race currentNuxt.close() against DEV_SHUTDOWN_TIMEOUT_MS, warn that the close hooks didn't finish, and go on with the reload. I can send a PR for that.
- Dominant language
- TypeScript
- Stars
- 402
- Forks
- 125
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 37
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nuxt/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
dev: false "reachable from the network" warning when `devServer.host` is a `*.localhost` subdomainMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
ai-driven-qa bug claude Cosmetic
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Domain / chatbot New
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Inist-CNRS/lodex#3861 ·
Maintainers usually reply within 1 day
-
area:agent-sdk area:docs documentation enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
anthropics/claude-code#110914 ·
-
area/cli platform/windows type/bug version/v2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
anomalyco/opencode#64631 · 1 comment ·
Maintainers usually reply within 1 day