-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
inspector: SIGUSR1 should use next available port if 9922 is already used #16872
Comments
I think you can use Ideally, if dynamic port assignment on
|
@auchenberg Does |
@bnoordhuis I wasn't aware that |
This would probably work for most peoples' scenarios. For us, it would pose a few problems:
|
You'd have to do that with @auchenberg's proposed scheme too, right? |
There were some discussions about giving programmatic control over the port selection (e.g. to allow user code/module to register a handler for the debug signal). Would this work for you? |
@eugeneo we love the signaling mechanism to put a Node process into inspect mode. Not sure if this would work, but here is a suggestion - On the signalling side, whenever a process is signaled - SIGUSR1, Node would pick a new unused port and use that. I guess node would have to find a way to fig. out random ports that are not being used. Doesn't it already do that today to check if 9229 is available? |
Not really, probably "too invasive" for our scenarios. So, we may have some work-arounds here that will be good enough. That said, if node runtime wanted to support dynamic port assignment, limited to a port range, and some reliable discovery mechanism, there'd be some switches like:
Then, a |
@bnoordhuis @mike-kaufman I understand the need for having a consistent discovery mechanism, and listening to What are the alternatives? Emit port on a predefined POSIX signal? |
Another thing that is in progress is subtargets - #16627 I think it should be possible for VSCode to run a "parrent" node and setup an inspector on it. Then it should be possible to send requests to start child nodes (once process.fork is supported for this scenario). |
@dhanvikapila I do not see how this could be implemented, 9229 might be taken by "unrelated" Node process (e.g. ran by a different user) or some non-Node process.
There is a requirement for inspector-over-pipe. It would likely look something like -inspector-pipe=/path/to/pipe. @mike-kaufman |
Alternatively, if you're on a UNIX-like system, it's not too onerous to find out what ports the target process was listening on before and after signalling it. Worst case you shell out to |
@eugeneo if my understanding is correct, event today if 9229 is unavailable, debugging will not work anyways since Node wont put the target process into inspect mode. Node cannot change this behavior without breaking backwards compatibility. I'm not claiming my proposal would be perfect but it provides a way forward when 9229 is available. @bnoordhuis |
@eugeneo - that almost works. Issue here is if that pre-identified port is in-use when SIGUSR1 is received. Maybe we can get away with it, but my concern is at high enough scale it will show up.
@bnoordhuis - yeah, that almost works too. Issue here is if node process opens an additional port between your
@auchenberg - I think it's safe to assume that if you specify a directory on command-line, there's perms sufficient to write to it. |
looks like the discussion has identified a couple of viable workarounds for the reported problem (pre-allocating ports, discovery using |
Since this issue hasn't seen any action in over a year I'm going to go ahead and close it out. Please reopen if necessary. |
When having multiple node processes running in parallel, and sending
SIGUSR1
to one of them the Inspector server started and binding inport 9222
. When sendingSIGUSR1
to another Node process, the Inspector server can't be started asport 9222
is already used.This limits debugging, and sending
SIGUSR1
to a process should start the Inspector server on the next available port instead of failing. The used port could be outputted tostdout
for detection.The text was updated successfully, but these errors were encountered: