-
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
Adapt "auto attach" feature to js-debug #88599
Comments
@connor4312 how do you want to transition this feature to js-debug? |
I'm curious whether the debug terminal in js-debug fills the niche that auto attach does with the existing debuggers. For me it's become my go-to way to debug code, though I admit that before starting work on debugging here I didn't know about auto-attach so haven't been a heavy user of it. Extra knowledge is needed for both use cases, to use --inspect in the normal terminal, or using the command to open the debug terminal. Thoughts? |
Yes, the debug terminal is definitively similar to "auto attach".
I'd prefer the second option because with this we could easily redirect existing users to the new feature. One technical aspect of the "auto attach" setting to keep in mind: |
Great work with the Debug Terminal, unfortunetly I did not give it much thought until today - sorry about that. The biggest issue with the debug terminal is how discoverable it is. Can the js-debug participate in new terminal creation? When a new terminal is created convert it to a Debugger Terminal? I dislike a command palette (not discoverable) and status bar: too much in your face. |
Participation in terminal creation is something that Kai and I discussed last month while I was working on the debug terminal improvements. I think adapting the "auto attach" button to debug terminals would be a nice way to go, we could have a migration for the existing on-by-default setting. Something like an I think participation in terminals in this case would be always on (with some user setting to forcefully disable), to set the environment variables and bootloader for each terminal. However, we wouldn't start the debug session server unless the "auto-attach" is on, and have our bootloader no-op if it can't connect to the server. This lets the auto-attach button instantly toggle the whether we debug processes in all terminals, without users having to create a new terminal or close old terminals if they no longer want to auto attach. I will also need to do some work to make sure that explicitly using the Related: #46696 (comment) |
Ok. Please note that how to enable / disable this behavior might be an interesting topic for the UX meeting. For instance I am not a big fan of having the status bar entry, so if we could get something in the actual terminal that would be great imho. |
@connor4312 what is the current state of your thinking? I'm trying to understand what an existing "auto-attach" user would experience with the new js-debug. Ideally it should "just work": she opens a terminal (which automatically has the bootloader enabled) and runs a node.js based program from the command line. That results in a new debug session. In addition starting up VS Code with "auto-attach" enabled, does not activate js-debug on startup but only when something is run from the (debug) terminal (the old approach of activating node-debug only when needed no longer works with the new bootloader approach because here an active js-debug is already required, correct?) |
@weinand we're discussing that, I think the current thinking is the extension's env contributions are cached between start up. I have concerns about that but it does work around the activate on startup problem.. |
The alternative is to use the existing autoAttach extension as a companion extension to js-debug too. autoAttach is very lightweight and activates on startup. So it could easily contribute the bootstrap env variable (even dynamically by code). |
I'm working on this now. I have it set so that js-debug sets the environment variables that injects the bootloader to debug processes. Thanks to the work Daniel did, this can be persistent between sessions so that we don't need to activate and inject the variable again each time. However, we do need the extension to activate when the first Node.js script is run in a terminal, so that we can detect and debug it. My thought is to tap into the existing auto-launch extension and use the js-debug pathway if the user has Setting environment variables needs to be done in js-debug so that they're automatically updated if the extension is uninstalled or updated. In summary: Turning on auto attach:
Turning off auto attach:
Receiving a debug target
@weinand does this approach + adding it to the existing auto-launch make sense to you? |
@connor4312 overall the approach sounds good to me. What I could not clearly see in your summary is what happens for users that currently have auto-attach on. Are they transparently "migrated" to the new Node.js debug terminal? |
They would be transparently migrated to the 'new' terminal/strategy once they turn the |
Sounds perfect. |
This modifies the debug-auto-launch extension to trigger js-debug as outlined in #88599 (comment) Since we now have four states, I moved the previous combinational logic to a `transitions` map, which is more clear and reliable. The state changes are also now a queue (in the form of a promise chain) which should avoid race conditions. There's some subtlety around how we cached the "ipcAddress" and know that environment variables are set. The core desire is being able to send a command to js-debug to set the environment variables only if they haven't previously been set--otherwise, reused the cached ones and the address. This process (in `getIpcAddress`) would be vastly simpler if extensions could read the environment variables that others provide, though there may be security considerations since secrets are sometimes stashed (though I could technically implement this today by manually creating and terminal and running the appropriate `echo $FOO` command). This seems to work fairly well in my testing. Fixes #88599.
* debug: enable js-debug to auto attach This modifies the debug-auto-launch extension to trigger js-debug as outlined in #88599 (comment) Since we now have four states, I moved the previous combinational logic to a `transitions` map, which is more clear and reliable. The state changes are also now a queue (in the form of a promise chain) which should avoid race conditions. There's some subtlety around how we cached the "ipcAddress" and know that environment variables are set. The core desire is being able to send a command to js-debug to set the environment variables only if they haven't previously been set--otherwise, reused the cached ones and the address. This process (in `getIpcAddress`) would be vastly simpler if extensions could read the environment variables that others provide, though there may be security considerations since secrets are sometimes stashed (though I could technically implement this today by manually creating and terminal and running the appropriate `echo $FOO` command). This seems to work fairly well in my testing. Fixes #88599. * fix typo * clear js-debug environment variables when disabling auto attach
I would expect that using the existing "auto attach" feature of node-debug applies to js-debug too.
The text was updated successfully, but these errors were encountered: