diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index 780a89e3f3f1..765bdf051d1f 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -193,6 +193,12 @@ async function createRouterWorker(fullConfig: NextConfigComplete): Promise<{ return { worker, cleanup: async () => { + // Remove process listeners for childprocess too. + for (const curWorker of ((worker as any)._workerPool?._workers || []) as { + _child?: ChildProcess + }[]) { + curWorker._child?.off('exit', cleanup) + } process.off('exit', cleanup) process.off('SIGINT', cleanup) process.off('SIGTERM', cleanup)