`nuxt dev` reload never finishes when a Nuxt `close` hook doesn't settle
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 72/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- node.js, nuxt, typescript
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 402
- Forks
- 125
- Ø Merge
- 2 T. 9 Std.
- Gemergte PRs (30 T.)
- 37
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus nuxt/cli
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
dev: false "reachable from the network" warning when `devServer.host` is a `*.localhost` subdomainEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
bug priority: low role: BE stage: now
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
ahmadrosid/nakama#2594 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
milind-soni/OpenMausBot#6495 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Navigating the session tree adds the branch's prompts to Up-arrow history againEvtl. vergeben @acmerfight hat das heute übernommen. Offenuntriaged
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
earendil-works/pi#12279 ·
Maintainer antworten meist innerhalb von 1 Tag
-
approved documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 89/100
vitest-dev/vitest#12015 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100