Skip to content

Set IsDebuggingRemoteRunspace sooner for attach #1815

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,26 @@ public async Task<LaunchResponse> Handle(PsesLaunchRequestArguments request, Can
}

public async Task<AttachResponse> Handle(PsesAttachRequestArguments request, CancellationToken cancellationToken)
{
// We want to set this as early as possible to avoid an early `StopDebugging` call in
// DoOneRepl. There's too many places to reset this if it fails so we're wrapping the
// entire method in a try here to reset it if failed.
//
// TODO: Ideally DoOneRepl would be paused until the attach is fully initialized, though
// the current architecture makes that challenging.
_debugService.IsDebuggingRemoteRunspace = true;
try
{
return await HandleImpl(request, cancellationToken).ConfigureAwait(false);
}
catch
{
_debugService.IsDebuggingRemoteRunspace = false;
throw;
}
}

private async Task<AttachResponse> HandleImpl(PsesAttachRequestArguments request, CancellationToken cancellationToken)
{
// The debugger has officially started. We use this to later check if we should stop it.
((PsesInternalHost)_executionService).DebugContext.IsActive = true;
Expand Down Expand Up @@ -413,7 +433,6 @@ await _executionService.ExecutePSCommandAsync(
// Clear any existing breakpoints before proceeding
await _breakpointService.RemoveAllBreakpointsAsync().ConfigureAwait(continueOnCapturedContext: false);

_debugService.IsDebuggingRemoteRunspace = true;
_debugStateService.WaitingForAttach = true;
Task nonAwaitedTask = _executionService
.ExecutePSCommandAsync(debugRunspaceCmd, CancellationToken.None, PowerShellExecutionOptions.ImmediateInteractive)
Expand Down