From 961a41eb45012dff34a66715b3998a2434281065 Mon Sep 17 00:00:00 2001 From: Tomas Fagerbekk Date: Mon, 2 Oct 2023 00:17:37 +0200 Subject: [PATCH 1/3] Test NODE_OPTION inspect option attaches debugger --- test/integration/cli/test/index.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/integration/cli/test/index.test.js b/test/integration/cli/test/index.test.js index 4c9f9bac53e9f..dec883c70eccd 100644 --- a/test/integration/cli/test/index.test.js +++ b/test/integration/cli/test/index.test.js @@ -496,6 +496,7 @@ describe('CLI Usage', () => { test("NODE_OPTIONS='--inspect'", async () => { const port = await findPort() let output = '' + let errOutput = '' const app = await runNextCommandDev( [dirBasic, '--port', port], undefined, @@ -503,11 +504,16 @@ describe('CLI Usage', () => { onStdout(msg) { output += stripAnsi(msg) }, + onStderr(msg) { + errOutput += stripAnsi(msg) + }, env: { NODE_OPTIONS: '--inspect' }, } ) try { await check(() => output, new RegExp(`http://localhost:${port}`)) + await check(() => errOutput, /Debugger listening on/) + expect(errOutput).not.toContain('address already in use') } finally { await killApp(app) } From f3d6ea5091fd184cf9b89aec2ff0acaa4d3359cc Mon Sep 17 00:00:00 2001 From: Tomas Fagerbekk Date: Sun, 1 Oct 2023 23:47:52 +0200 Subject: [PATCH 2/3] Do not forward inspect NODE_OPTION to workers closes: #55862 --- packages/next/src/cli/next-dev.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index 70546ea42f008..04886f7545c4e 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -2,7 +2,12 @@ import '../server/lib/cpu-profile' import type { StartServerOptions } from '../server/lib/start-server' -import { RESTART_EXIT_CODE, getPort, printAndExit } from '../server/lib/utils' +import { + RESTART_EXIT_CODE, + getPort, + printAndExit, + getNodeOptionsWithoutInspect +} from '../server/lib/utils' import * as Log from '../build/output/log' import { CliCommand } from '../lib/commands' import { getProjectDir } from '../lib/get-project-dir' @@ -251,6 +256,7 @@ const nextDev: CliCommand = async (args) => { stdio: 'inherit', env: { ...defaultEnv, + NODE_OPTIONS: getNodeOptionsWithoutInspect(), TURBOPACK: process.env.TURBOPACK, NEXT_PRIVATE_WORKER: '1', NODE_EXTRA_CA_CERTS: options.selfSignedCertificate From 88b8364fe03e3a28b842a97be4ad39ec271e6203 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Thu, 7 Dec 2023 20:07:40 +0100 Subject: [PATCH 3/3] Update packages/next/src/cli/next-dev.ts --- packages/next/src/cli/next-dev.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/next/src/cli/next-dev.ts b/packages/next/src/cli/next-dev.ts index e66d3606783d5..02e920d6971cc 100644 --- a/packages/next/src/cli/next-dev.ts +++ b/packages/next/src/cli/next-dev.ts @@ -247,7 +247,6 @@ const nextDev: CliCommand = async (args) => { stdio: 'inherit', env: { ...defaultEnv, - NODE_OPTIONS: getNodeOptionsWithoutInspect(), TURBOPACK: process.env.TURBOPACK, NEXT_PRIVATE_WORKER: '1', NODE_EXTRA_CA_CERTS: options.selfSignedCertificate