Skip to content

Delay launch/attach until after config done #2250

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jborean93
Copy link
Contributor

@jborean93 jborean93 commented Jul 28, 2025

PR Summary

Updates the sequence of launching and attaching scripts until after
configuration done is received. This aligns the behviour of starting a
debug session with other debug adapters. A side effect of this change is
that it is now possible to set breakpoints and do other actions in an
attached runspace target during the initialisation.

Also adds a new option NotifyOnAttach for an attach request which will
create the PSES.Attached event before calling Debug-Runspace
allowing attached scripts to wait for an attach event.

PR Context

Fixes: #2191
Fixes: #2245

The changes include the commit from #2251 which includes some test runner changes and to verify all the recent stuff added by myself work properly. I'll take this out of draft once we know what is happening with #2251.

PR to document new option in vscode-powershell PowerShell/vscode-powershell#5249.

@jborean93
Copy link
Contributor Author

Also have opened PowerShell/PowerShell#25788 which adds an event and public API to determine when Debug-Runspace has attached itself to a Runspace. This will help provide an official public API for new PowerShell versions if attached but the proposed notifyAttach option here will be good for older PowerShell versions.

Adds the `pathMappings` option to the debugger that can be used to map a
local to remote path and vice versa. This is useful if the local
environment has a checkout of the files being run on a remote target but
at a different path. The mappings are used to translate the paths that
will the breakpoint will be set to in the target PowerShell instance. It
is also used to update the stack trace paths received from the remote.

For a launch scenario, the path mappings are also used when launching a
script if the integrated terminal has entered a remote runspace.
@jborean93 jborean93 force-pushed the set-configuration branch 3 times, most recently from 85d20a9 to 3b58a91 Compare August 6, 2025 03:52
Updates the sequence of launching and attaching scripts until after
configuration done is received. This aligns the behaviour of starting a
debug session with other debug adapters. A side effect of this change is
that it is now possible to set breakpoints and do other actions in an
attached runspace target during the initialisation.

Also adds a new option `NotifyOnAttach` for an attach request which will
create the `PSES.Attached` event before calling `Debug-Runspace`
allowing attached scripts to wait for an attach event.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Write event on configurationDone for attach requests Bring launch sequencing in line with DAP spec
1 participant