vscode-js-debug
vscode-js-debug copied to clipboard
`autoAttachSmartPattern` should also apply to `autoAttachChildProcesses`
It’s expensive & time-consuming to automatically attach debuggers to every child process when using a task runner like yarn. We don’t need to attach to the yarn process, but can end up getting a large chain of attached debuggers, when we only want to debug the leaf process.
We can fix this in the integrated terminal only by configuring like so:
{
"debug.javascript.autoAttachFilter": "smart",
"debug.javascript.autoAttachSmartPattern": ["<PATH_TO_DESIRED_PROGRAM>"]
}
This prevents attaching to everything except the leaf processes that you specify, which greatly improves startup time.
However, this functionality is only enabled in the integrated terminal—nowhere else supports autoAttachSmartPattern.
I think that we should enable autoAttachSmartPattern in the launch.json options and it would function the same way.
Apologies if I’m missing something—I pored over the docs but I couldn’t find a different way to make this work.
Good suggestion, we actually had this in early versions of this tool but never got around to reimplementing it... Would not be terribly difficult to PR if you're interested.
Debugging works by the inclusion of a "bootloader" script in NODE_OPTIONS that is required before the program starts. Code that runs in the bootloader to determine if we should attach to the child process:
https://github.com/microsoft/vscode-js-debug/blob/1f824e7afff188539129933bd01cc4cab39f9efd/src/targets/node/bootloader.ts#L203-L213
Code that sets the variables that the bootloader gets:
https://github.com/microsoft/vscode-js-debug/blob/1f824e7afff188539129933bd01cc4cab39f9efd/src/targets/node/nodeLauncherBase.ts#L301-L318
Configuration interface where the option could be added:
https://github.com/microsoft/vscode-js-debug/blob/1f824e7afff188539129933bd01cc4cab39f9efd/src/configuration.ts#L286