-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Auto attach debugger to Node processes started from integrated terminal #42521
Comments
Suggestion from @roblourens: "What if in the existing process picker, we find processes that were started from the integrated terminal, and sort them to the top/highlight them?" |
@auchenberg I've started a "Playground" extension for experimenting with this feature. Since there is no API for accessing existing terminals, the extension just tries to automatically attach to all node runtimes that are in debug mode. Ideas for more features:
|
Here's the feature request to expose all the terminals to the API #13267, it's mainly just been waiting for compelling use cases. I've wanted to track the terminal process trees for a while as well to give a better experience for |
I like that experience @weinand, as the developer intentionally have chosen to enable ``--inspect`. We could have the out of box experience like:
I still can't decide whether pressing F5 for Node apps where we know a Node child process has been launched from the terminal should change behavior from today, as you can argue both ways. That said I can easily imagine a workflow where I from my terminal type Today the experience somewhat falls apart if you already have started from the terminal, as we would try to launch the Node process again, and it would most likely fail as the port already is used. This would be a change in the default F5 logic with no launch.json:
What do you think? |
@Tyriar tracking process trees for VS Code or the integrated terminal works as long as child process are created under a well known VS Code or integrated terminal process. But when running "tmux" in the integrated terminal, spawned process becomes children of a remote tmux server. So they are no longer part of the VS Code tree. Do you have any ideas how to track those processes? |
The February exploration has been finished. For the next milestone it is planned:
|
Perhaps you can query the actual tmux process using the pid of the terminal process? |
Thanks, yes that was my thinking too... |
Node debug (both protocols) got these new features:
@auchenberg please give it a try and let me know what we should ship in March. |
@weinand Just gave it a spin. My initial feedback: I think the discoverability of the new auto attach button in the status bar is quite limited. I had to look for it and hover the item to read the title to figure out what it does. To improve discoverability could we:
I don't see the new |
I think there's still the performance concern on Windows of using wmic to poll the processes that can hammer the CPU. |
I agree with @Tyriar. Last month we made use of an npm package in the Python extension and uses |
@RMacfarlane is making good progress on improvements to windows-process-tree and it should soon support everything needed by auto attach (arg list, process as a list not tree) microsoft/vscode-windows-process-tree#12. |
@Tyriar great! I'll jump on it as soon as possible... |
In the March release the feature is not yet on by default (and consequently there is no prompt notification) due to the performance concern on Windows. I'll keep the status bar item in the interim. I've tried to avoid the performance issues by only starting another However, I will not improve the discoverability of the auto-attach feature in this milestone because there is still potential for performance issues on Windows. I'm waiting for @Tyrar and @RMacfarlane for an improved version of the |
@weinand we published the module this morning and @RMacfarlane pulled it into vscode master. So it's good to go. Note that we haven't actually tested the new APIs yet inside VS Code, only hooked up the old one which seems to work fine. |
@weinand you will want to use |
@Tyriar Will this be available for use by other extension authors via some vscode api. I know it's an npm package, but the fact that it's got native dependencies make it difficult to package with extensions. |
@DonJayamanne I think extensions can just import VS Code's node modules, we don't explicitly make that public API so it could break across versions though. |
Yes I suspected that, hence the question about it being exposed via VS Code API. A shame we cannot implement this in the Python extension due to the above limitation. To be honest this seems a little unfair. |
@DonJayamanne I pinged the team on Slack about this. I was actually thinking about whether an API on |
Yes, that would be great. |
@DonJayamanne created #46737 to track |
@DonJayamanne sorry but your statement:
is not true. Node debugging is developed as an independent extension and the fact that it is shipping with VS Code does not mean that we are not playing by the rules. So we are not "reaching into" VS Code for accessing node modules. @Tyriar for the March release we (Node Debugging) will not switch to use the |
I didn't mean anything if that sorts. @Tyriar thanks for considering to make this a public API. |
Scenario
I as a Node developer use the integrated terminal to launch my Node.js app as I'm used to. My app starts, and now I want to debug. I could make a debug configuration to launch my Node app via VS Code, but that would be a new workflow for me. Instead I want VS code to be able to attach to my started Node process from the terminal.
Proposal
We should explore auto attaching to our Node debugger to the first Node process started from the integrated terminal.
Flow:
npm start
This could either happen automatically as a part of our magic out of box experience, or through a new property in the debug configuration.
Rationale
The text was updated successfully, but these errors were encountered: