-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
debugger: bind to random port with --debug-port=0 #5025
Conversation
This looks like a |
src/node.cc
Outdated
fprintf(stderr, "Starting debugger on port %d failed\n", debug_port); | ||
fflush(stderr); | ||
return; |
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.
Why this is necessary?
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.
It's the opposite of necessary, the return
statement isn't necessary. :-)
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.
Duh :D In my defense I was Reviewing in mobile.
I think, new CLI parameter is not required. Old Also, debuggers use update: it seems, issue title is not correct — new logic is applied to all 3 flags and not bound only to |
We (JetBrains) like this solution. #4419 is too magic. Node is an engine. Strictly speaking, it should be handled on an application level. Node feature But as result, tools like AVA will be debuggable without any efforts from tool author. |
It's not new, it's an existing command line switch.
Correct, but that doesn't fit in 50 columns. :-) |
LGTM |
1 similar comment
LGTM |
lib/_debug_agent.js
Outdated
@@ -21,7 +21,7 @@ exports.start = function start() { | |||
agent.listen(process._debugAPI.port, function() { | |||
var addr = this.address(); | |||
process._rawDebug('Debugger listening on port %d', addr.port); | |||
process._debugAPI.notifyListen(); | |||
process._debugAPI.notifyListen(addr.port); |
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.
so could it be possible that an error was passed to the callback from listen and this.address().port
is undefined? If so, that would cause an abort in debug-agent right? Should we guard for that?
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.
net.Server#listen()
doesn't work that way, it emits an 'error' event when it can't bind to a port.
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.
Ah good point. I was incorrectly assuming that the connection listener would still be called, just with an error. Carry on
LGTM |
New CI attempt: https://ci.nodejs.org/job/node-test-pull-request/1504/ - previous one was hit by a network outage, it looks like. |
LGTM |
Grr, more RemotingSystemExceptions and IOExceptions. One more try: https://ci.nodejs.org/job/node-test-pull-request/1506/ |
A seemingly genuine failure on one of the Windows buildbots:
Exit code |
I suspect the failure is unrelated and only exposed, not caused, by this change. Added another test to validate that. CI: https://ci.nodejs.org/job/node-test-pull-request/1543/ EDIT: To be clear, the second commit is not supposed to land as-is. |
Interestingly, the new test passes on all platforms. The old test passes too except on win10+vs2015; win2012r2+vs2015 and win20082r2+vs2013 are fine. I'm inclined to scrap the previous test and go with the new one. |
How we can receive information about debug port of each child from cluster master? |
Can I get one more round of review? I worked over the test and added two more. The gist of the PR hasn't changed but I had to add some machinery to make testing reliable. |
@3y3 Take a look at the cluster test I just added. If you start the master with |
worker.send('debugPort'); | ||
} | ||
process.on('exit', () => { | ||
assert(ports.every((port) => port > 0)); |
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.
Maybe port > 1024
?
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.
Yes, that would be more correct.
@bnoordhuis ... what's the status on this? |
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.
Updated, @sam-github PTAL. CI: https://ci.nodejs.org/job/node-test-pull-request/8332/
Question: should the call to env->inspector_agent()->Start()
call debug_options.set_port()
?
I think the options should mirror what was set on the CLI (or the default), IMO., anything else is more confusing. When the listener is stopped and started the port will change. |
@sam-github Can you (re)review? It's not clear to me if you were asking me to change anything. |
Ben:
Sam: |
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.
Still LGTM
Allow binding to a randomly assigned port number with `--inspect=0` or `--inspect-brk=0`. PR-URL: nodejs#5025 Refs: nodejs#4419 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
sorry to comment on a closed issue, just one question, is this change present in latest |
I just replied to nodejs/help#649 but to answer your question, I expect it will be released in v8.1.0. |
thnks! |
Allow binding to a randomly assigned port number with `--inspect=0` or `--inspect-brk=0`. PR-URL: #5025 Refs: #4419 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
* **Async Hooks** * When one `Promise` leads to the creation of a new `Promise`, the parent `Promise` will be identified as the trigger [[`135f4e6643`](nodejs@135f4e6643)] [nodejs#13367](nodejs#13367). * **Dependencies** * libuv has been updated to 1.12.0 [[`968596ec77`](nodejs@968596ec77)] [nodejs#13306](nodejs#13306). * npm has been updated to 5.0.3 [[`ffa7debd7a`](nodejs@ffa7debd7a)] [nodejs#13487](nodejs#13487). * **File system** * The `fs.exists()` function now works correctly with `util.promisify()` [[`6e0eccd7a1`](nodejs@6e0eccd7a1)] [nodejs#13316](nodejs#13316). * fs.Stats times are now also available as numbers [[`c756efb25a`](nodejs@c756efb25a)] [nodejs#13173](nodejs#13173). * **Inspector** * It is now possible to bind to a random port using `--inspect=0` [[`cc6ec2fb27`](nodejs@cc6ec2fb27)] [nodejs#5025](nodejs#5025). * **Zlib** * A regression in the Zlib module that made it impossible to properly subclasses `zlib.Deflate` and other Zlib classes has been fixed. [[`6aeb555cc4`](nodejs@6aeb555cc4)] [nodejs#13374](nodejs#13374).
* **Async Hooks** * When one `Promise` leads to the creation of a new `Promise`, the parent `Promise` will be identified as the trigger [[`135f4e6643`](135f4e6643)] [#13367](#13367). * **Dependencies** * libuv has been updated to 1.12.0 [[`968596ec77`](968596ec77)] [#13306](#13306). * npm has been updated to 5.0.3 [[`ffa7debd7a`](ffa7debd7a)] [#13487](#13487). * **File system** * The `fs.exists()` function now works correctly with `util.promisify()` [[`6e0eccd7a1`](6e0eccd7a1)] [#13316](#13316). * fs.Stats times are now also available as numbers [[`c756efb25a`](c756efb25a)] [#13173](#13173). * **Inspector** * It is now possible to bind to a random port using `--inspect=0` [[`cc6ec2fb27`](cc6ec2fb27)] [#5025](#5025). * **Zlib** * A regression in the Zlib module that made it impossible to properly subclasses `zlib.Deflate` and other Zlib classes has been fixed. [[`6aeb555cc4`](6aeb555cc4)] [#13374](#13374).
* **Async Hooks** * When one `Promise` leads to the creation of a new `Promise`, the parent `Promise` will be identified as the trigger [[`135f4e6643`](135f4e6643)] [#13367](#13367). * **Dependencies** * libuv has been updated to 1.12.0 [[`968596ec77`](968596ec77)] [#13306](#13306). * npm has been updated to 5.0.3 [[`ffa7debd7a`](ffa7debd7a)] [#13487](#13487). * **File system** * The `fs.exists()` function now works correctly with `util.promisify()` [[`6e0eccd7a1`](6e0eccd7a1)] [#13316](#13316). * fs.Stats times are now also available as numbers [[`c756efb25a`](c756efb25a)] [#13173](#13173). * **Inspector** * It is now possible to bind to a random port using `--inspect=0` [[`cc6ec2fb27`](cc6ec2fb27)] [#5025](#5025). * **Zlib** * A regression in the Zlib module that made it impossible to properly subclasses `zlib.Deflate` and other Zlib classes has been fixed. [[`6aeb555cc4`](6aeb555cc4)] [#13374](#13374).
Release team decided not to backport to v6.x, as the inspector is substantially different in that version, let us know if you think it should be backported. |
Is this feature documented somewhere? I wasn't able to find much information about it. |
Allow binding to a randomly assigned port number with
--debug-port=0
.Refs: #4419
R=@indutny