-
Notifications
You must be signed in to change notification settings - Fork 58
Support dynamic port assignment via --inspect-port=0 #153
Comments
Didn't even know about that feature, but this is easy to support. cc @weinand |
Me neither, learned about it in nodejs/node#16872 (comment) |
Hmmm. Since the DA is attaching (and not launching), how can we read the stdout of the debuggee in order to detect the port? In addition, attaching by process ID is useful if node has been started without any debug/inspect arguments. So if we have to use But may be I'm not really understanding this feature. It's too late... :-) |
I skimmed this and assumed the launch config had the port in it. If we have to detect the port from stdout then we would have to use some platform-specific method of getting the stdout of a process that isn't a child process. I have no idea how to do that on windows, I don't even know if it's possible. It also seems like there could be issues with node's debug output getting mixed in with output from the user code. |
It looks easy on linux, but the Mac solution is scary: https://stackoverflow.com/questions/3425340/how-can-i-capture-the-stdout-from-a-process-that-is-already-running |
@weinand The scenario here is that |
We already have code in node-debug that detects a port based on a process ID: https://github.com/Microsoft/vscode-node-debug/blob/424c7760fd197e29ad7a8bd20234d9dbbd534163/src/node/extension/protocolDetection.ts#L154 And please note that the SIGUSR1 mechanism only works locally. So you cannot send signals to a remote process. |
Because this is somewhat related, I'm linking to the PR: #235 Would like to get some additional feedback regarding this. Thanks @roblourens so far for your assistance as well. |
@roblourens following up on this and what @weinand mentioned, it seems like (if we still want to do this), the approach would be:
Thoughts? |
It's possible to start Node with
node --inspect-port=0
that assignes a dynamic port to the inspector server.When using it together with a dynamic attach config like:
We end up failing to attach, as we try on the default port
but the Inspector server is running the dynamically assigned port
Idea: When the given process has been selected, attach to the strout, parse the output to find the used port. use that for attach
The text was updated successfully, but these errors were encountered: