Unverified Commit 9f08ef8d authored by Seiry Yu's avatar Seiry Yu Committed by GitHub

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: 's avatarSeiry Yu <seiry@squareup.com>
parent 9be98e4a
...@@ -477,22 +477,27 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit ...@@ -477,22 +477,27 @@ If you cannot make the changes above, but still want to try out\nNext.js v13 wit
let config: NextConfig let config: NextConfig
let childProcess: ChildProcess | null = null let childProcess: ChildProcess | null = null
const isDebugging = process.execArgv.some((localArg) => const isDebugging =
localArg.startsWith('--inspect') process.execArgv.some((localArg) => localArg.startsWith('--inspect')) ||
) process.env.NODE_OPTIONS?.match?.(/--inspect(=\S+)?( |$)/)
const isDebuggingWithBrk = process.execArgv.some((localArg) => const isDebuggingWithBrk =
localArg.startsWith('--inspect-brk') process.execArgv.some((localArg) =>
) localArg.startsWith('--inspect-brk')
) || process.env.NODE_OPTIONS?.match?.(/--inspect-brk(=\S+)?( |$)/)
const debugPort = (() => { const debugPort = (() => {
const debugPortStr = process.execArgv const debugPortStr =
.find( process.execArgv
(localArg) => .find(
localArg.startsWith('--inspect') || (localArg) =>
localArg.startsWith('--inspect-brk') localArg.startsWith('--inspect') ||
) localArg.startsWith('--inspect-brk')
?.split('=')[1] )
?.split('=')[1] ??
process.env.NODE_OPTIONS?.match?.(
/--inspect(-brk)?(=(\S+))?( |$)/
)?.[3]
return debugPortStr ? parseInt(debugPortStr, 10) : 9229 return debugPortStr ? parseInt(debugPortStr, 10) : 9229
})() })()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment