-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
fix(debugger): accept arbitrary ip and port as NODE_OPTIONS #53683
Conversation
214fdfb
to
5541fa2
Compare
Is there a version we can use that does not have the bug that is fixed in this PR? |
Agreed, would be great to prioritize this issue and get a fix in 13.4.20. |
Update ports exposed, and run the next server with inspect flag Currently does not work due to bug in next.js See related PR: vercel/next.js#53683
5541fa2
to
0001765
Compare
const testAllIPsAndPorts = async (someIp) => { | ||
const testIps = [ | ||
'0.0.0.0', | ||
'127.0.0.1', | ||
'localhost', | ||
'192.168.18.90', | ||
'barcos.co', | ||
'app.barcos.co', | ||
] | ||
for (const someIp of testIps) { | ||
const port = await findPort() | ||
test(`NODE_OPTIONS='--inspect=${someIp}:${port}'`, async () => { | ||
let output = '' | ||
const app = await runNextCommandDev( | ||
[dirBasic, '--port', port], | ||
undefined, | ||
{ | ||
onStdout(msg) { | ||
output += stripAnsi(msg) | ||
}, | ||
env: { NODE_OPTIONS: `--inspect=${someIp}:${port}` }, | ||
} | ||
) | ||
try { | ||
await check(() => output, new RegExp(`on ${someIp}:${port}`)) | ||
await check(() => output, new RegExp(`http://${someIp}:${port}`)) | ||
} finally { | ||
await killApp(app) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
testAllIPsAndPorts() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! But test case names should be determanistic, not dynamically generated.
Could you update this such that the for loop is inside the test case? So you would have something like:
test("NODE_OPTIONS='--inspect=<host>:<port>'", async () => {
const hosts = [
'0.0.0.0',
'127.0.0.1',
'localhost',
'192.168.18.90',
'barcos.co',
'app.barcos.co',
null,
]
for (const host of hosts) {
const port = await findPort()
// ...
}
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I made the changes just a couple of minutes ago; I had a lot of work to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wyattjoh, do I need to do anything else? This MR could be beneficial for many developers who prefer not to debug using console logs.
Indeed, this issue has been going on for 7-8 months now in which it is completely impossible to debug next.js in a docker container. Is it possible to give the review of these 10 lines of code priority? |
The PR was already reviewed but the comments were not addressed yet, so this can't be landed as-is. Feel free to open a new PR based on this one to fix that, happy to land it when the comments are addressed. |
b9dd6ac
to
dd509c2
Compare
@timneutkens @wyattjoh How I said I had a lot of work to do. But now the MR should be ready to merge |
894d346
to
c2473a2
Compare
Hope it's OK to ask this question again, since this PR appears to be held up again. |
Any updates for this PR? |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
1 similar comment
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Any update on this? Currently it's impossible to debug a NextJS application running in a docker container. |
Should I do anything? I don't see any approvals or changes requested after 1 month. |
@timneutkens Hey, could you have another look at this PR? I believe @HelmerBarcos has addressed the remarks. |
c2473a2
to
691c68f
Compare
I didn't see this PR before opening a very similar one here - #59410 The only real difference I think is that I've also added ability to set the host. It didn't look like this is actually passing along the host to NODE_OPTIONS. I pulled the tests over from this PR to mine as well. Not a concern to me which one gets merged, but it'd be nice to get this in so that we can have debugging supported in docker containers. |
691c68f
to
2d0af87
Compare
Im closing this PR and opening a new one. See #60919 |
What?
This enables debugging sessions from a remote host. This is helpful while debugging a Next.js application that runs inside a Docker container with following possibilities inside the
package.json
:Bug
This fixes:
Other "fixed" bugs
Why?
It was an attempt to fix the bug, but it didn't work for all the cases.
Keep in mind that the default host will be
127.0.0.1
, and this will be blocked for external hosts trying to attach to the debugger. TheNODE_OPTIONS
should be set toNODE_OPTIONS='--inspect=0.0.0.0:SOME_PORT'
.https://nodejs.org/en/docs/guides/debugging-getting-started#security-implications