Skip to content

Commit 9f08ef8

Browse files
fix: Add NODE_OPTIONS for debugging in next-dev (#46757)
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: --> ## Bug fix #46948 - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by: Seiry Yu <seiry@squareup.com>
1 parent 9be98e4 commit 9f08ef8

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

packages/next/src/cli/next-dev.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -477,22 +477,27 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
477477
let config: NextConfig
478478
let childProcess: ChildProcess | null = null
479479

480-
const isDebugging = process.execArgv.some((localArg) =>
481-
localArg.startsWith('--inspect')
482-
)
480+
const isDebugging =
481+
process.execArgv.some((localArg) => localArg.startsWith('--inspect')) ||
482+
process.env.NODE_OPTIONS?.match?.(/--inspect(=\S+)?( |$)/)
483483

484-
const isDebuggingWithBrk = process.execArgv.some((localArg) =>
485-
localArg.startsWith('--inspect-brk')
486-
)
484+
const isDebuggingWithBrk =
485+
process.execArgv.some((localArg) =>
486+
localArg.startsWith('--inspect-brk')
487+
) || process.env.NODE_OPTIONS?.match?.(/--inspect-brk(=\S+)?( |$)/)
487488

488489
const debugPort = (() => {
489-
const debugPortStr = process.execArgv
490-
.find(
491-
(localArg) =>
492-
localArg.startsWith('--inspect') ||
493-
localArg.startsWith('--inspect-brk')
494-
)
495-
?.split('=')[1]
490+
const debugPortStr =
491+
process.execArgv
492+
.find(
493+
(localArg) =>
494+
localArg.startsWith('--inspect') ||
495+
localArg.startsWith('--inspect-brk')
496+
)
497+
?.split('=')[1] ??
498+
process.env.NODE_OPTIONS?.match?.(
499+
/--inspect(-brk)?(=(\S+))?( |$)/
500+
)?.[3]
496501
return debugPortStr ? parseInt(debugPortStr, 10) : 9229
497502
})()
498503

0 commit comments

Comments
 (0)