-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging with NODE_OPTIONS='--inspect=0.0.0.0' next dev causes errors #53127
Comments
I think it's broken in the latest version, even |
Its is a duplication of #47083. I will create a PR in order to fix this. This should help people debugging an nextjs application that runs inside a docker container |
Any update on this? Currently it's impossible to debug a NextJS application running in a docker container. |
I used ssh tunnels to work around this |
I also ran into it while trying to debug Workaround: change this line to: NODE_OPTIONS = `${NODE_OPTIONS} --${nodeDebugType}=0.0.0.0:9230`; then:
And another relevant link: P.S. This must be an anti-reverse-engineering kind of bug :) |
I tried the fix from x-yuri but its still not working for me (using the node alpine 3.18 img with Is there any fix comming? Or did I miss something? |
@StefanMeindlDatenKraft I just confirmed that the workaround works. If it still doesn't for you, I expect a long explanation, as I did. |
Thanks for the quick reply but still no luck. Here is what I did: I have a custom image for the node alpine image and I defined the entry point like this:
Then I connected to the container using Here is the console output:
|
@x-yuri what was your output from next js? Did it also start two debugger for you on 9229 and 9230? |
@StefanMeindlDatenKraft Yep.
later on. For some reason you get 2 such messages. Which means it tries to fork 3 processes. Not sure what it means. I don't see your debugger connecting to the Try to follow the steps in the gist exactly. Does it work with a freshly made You say that it doesn't work. That's not informative at all. What exactly happens? You don't see the On a side note, I believe |
Yeah that is what I meant, it does not show up in I do have a docker-compose.yml where I expose the app port, Btw thanks for the tip @x-yuri with |
When I do "address already in use" is expected. My patch makes all children try to use For |
So the problem was with the docker configuration, I am still trying to figure out what the difference between my config and the docker run config of yours is, but when I use the docker run ... alpine:3.18 it works and I can inspect. I will post again when I find the issue. Thanks for your help and quick replies @x-yuri |
I regret to inform that I am not able to read. In my docker-compose.yml I had following configuration:
after changing it to |
Is there any progress or workaround for this issue? I need to debug an issue that only happens inside a container and I cannot seem to attach the debugger. Passing |
As mentioned in @x-yuri s guide you have to change the sourcecode of next with this command: |
That did it, thanks very much. |
Workaround also works for me! |
Worth pointing out that the workaround shows how easy this would be to fix. Let's get the fix in a release. |
Currently still relevant issue. |
<!-- 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: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> ### What? Previously, parsing and managing the `NODE_OPTIONS` was performed using a series of regular expressions. These were prone to bugs, and have already caused a few issues. This moves us over to the standard `parseArgs` ([docs](https://nodejs.org/docs/latest/api/util.html#utilparseargsconfig)): ```js import { parseArgs } from "node:utils" ``` ### Why? This simplifies the argument parser dramatically, removing the need for any special patterns or accommodations. No need to maintain all these patterns when there's a lightweight built-in parser already available. Fixes #53127 Fixes #53757 Fixes #47083 Fixes #50489 Closes #60919 Closes #59410 Closes NEXT-3219
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 ZEN SMP PREEMPT_DYNAMIC Tue, 04 Jul 2023 08:39:22 +0000 Binaries: Node: 20.3.1 npm: 8.19.2 Yarn: N/A pnpm: 8.6.6 Relevant Packages: next: 13.4.12 eslint-config-next: 13.0.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://github.com/vercel/next.js/blame/8d83d85e5359146bbbd0f96ea2f8490e7d6bc9cd/packages/next/src/cli/next-dev.ts#L488
To Reproduce
NODE_OPTIONS='--inspect=0.0.0.0' next dev
Describe the Bug
NodeJS's --inspect switch takes an optional address as a parameter that isn't being honored by Next. Next crashes when that is present.
spec: --inspect[=[host:]port]
https://nodejs.org/api/cli.html#--inspecthostport
In order to be able to expose a debugger from inside a Docker container, it has to listen on 0.0.0.0 instead of the default 127.0.0.1. To do that, we have to specify --inspect=0.0.0.0:9229.
The result of doing this is:
This and the root cause has been clearly described earlier in: #47083 but not fixed, as mentioned by gregmartyn in #47083 (comment)
This has also been described in (and presumably fixed but not accepted) in #47671
Expected Behavior
Start node debugger on 0.0.0.0 and default ports 9232 & 9233 instead of parsing "0.0.0.0" as a port only integer.
Honor the node --inspect switch parameters.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: