From 6bca120d02cc974ee74fd0a12c73e21d512948d3 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 12 Jun 2024 20:55:24 +0100 Subject: [PATCH] fix(nuxt): close top-level watcher on nuxt 'close' (#27571) --- packages/nuxt/src/core/builder.ts | 1 + packages/nuxt/src/core/nuxt.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/core/builder.ts b/packages/nuxt/src/core/builder.ts index c66e33c198..ca1b41dfd7 100644 --- a/packages/nuxt/src/core/builder.ts +++ b/packages/nuxt/src/core/builder.ts @@ -136,6 +136,7 @@ function createGranularWatcher () { console.timeEnd('[nuxt] builder:chokidar:watch') } }) + nuxt.hook('close', () => watcher?.close()) } } diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index b64525af10..6d4d62524e 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -49,7 +49,10 @@ export function createNuxt (options: NuxtOptions): Nuxt { addHooks: hooks.addHooks, hook: hooks.hook, ready: () => initNuxt(nuxt), - close: () => Promise.resolve(hooks.callHook('close', nuxt)), + close: async () => { + await hooks.callHook('close', nuxt) + hooks.removeAllHooks() + }, vfs: {}, apps: {}, }