From 8f977c9f6b16391f815a927533c763cdc5e7864f Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Mon, 14 Aug 2023 00:48:32 +0200 Subject: [PATCH] wip --- packages/next/src/server/lib/router-server.ts | 2 +- .../next/src/server/lib/setup-server-worker.ts | 15 ++++++--------- packages/next/src/server/lib/start-server.ts | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/next/src/server/lib/router-server.ts b/packages/next/src/server/lib/router-server.ts index 3afbd23004f96..6d711ba67a234 100644 --- a/packages/next/src/server/lib/router-server.ts +++ b/packages/next/src/server/lib/router-server.ts @@ -267,7 +267,7 @@ export async function initialize(opts: { const cleanup = async (err: Error | undefined) => { if (err) { - await devInstance?.logErrorWithOriginalStack(err) + await devInstance?.logErrorWithOriginalStack(err, 'uncaughtException') } debug('router-server process cleanup') diff --git a/packages/next/src/server/lib/setup-server-worker.ts b/packages/next/src/server/lib/setup-server-worker.ts index 87332d47fa597..52a5fef531494 100644 --- a/packages/next/src/server/lib/setup-server-worker.ts +++ b/packages/next/src/server/lib/setup-server-worker.ts @@ -9,16 +9,13 @@ import '../node-polyfill-fetch' import { warn } from '../../build/output/log' import { Duplex } from 'stream' -// `pages` will be in the same process as the router -if (process.env.__NEXT_PRIVATE_RENDER_WORKER === 'app') { - process.on('unhandledRejection', (err) => { - console.error(err) - }) +process.on('unhandledRejection', (err) => { + console.error(err) +}) - process.on('uncaughtException', (err) => { - console.error(err) - }) -} +process.on('uncaughtException', (err) => { + console.error(err) +}) export const WORKER_SELF_EXIT_CODE = 77 diff --git a/packages/next/src/server/lib/start-server.ts b/packages/next/src/server/lib/start-server.ts index f761c2db40144..f57620a209069 100644 --- a/packages/next/src/server/lib/start-server.ts +++ b/packages/next/src/server/lib/start-server.ts @@ -206,9 +206,11 @@ export async function startServer({ process.exit(1) } + console.log(process.env.__NEXT_PRIVATE_RENDER_WORKER) const cleanup = () => { debug('start-server process cleanup') server.close() + // process.exit(1) } process.on('exit', cleanup) process.on('SIGINT', cleanup)