Skip to content

Commit

Permalink
fix: Add NODE_OPTIONS for debugging in next-dev (#46757)
Browse files Browse the repository at this point in the history
<!--
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>
  • Loading branch information
seiry and seiryIsNotABlock authored Mar 9, 2023
1 parent 9be98e4 commit 9f08ef8
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 childProcess: ChildProcess | null = null

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

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

const debugPort = (() => {
const debugPortStr = process.execArgv
.find(
(localArg) =>
localArg.startsWith('--inspect') ||
localArg.startsWith('--inspect-brk')
)
?.split('=')[1]
const debugPortStr =
process.execArgv
.find(
(localArg) =>
localArg.startsWith('--inspect') ||
localArg.startsWith('--inspect-brk')
)
?.split('=')[1] ??
process.env.NODE_OPTIONS?.match?.(
/--inspect(-brk)?(=(\S+))?( |$)/
)?.[3]
return debugPortStr ? parseInt(debugPortStr, 10) : 9229
})()

Expand Down

0 comments on commit 9f08ef8

Please sign in to comment.