@@ -55,7 +55,7 @@ public DebugAdapter(
55
55
}
56
56
57
57
/// <summary>
58
- /// Gets a boolean that indicates whether the current debug adapter is
58
+ /// Gets a boolean that indicates whether the current debug adapter is
59
59
/// using a temporary integrated console.
60
60
/// </summary>
61
61
public bool IsUsingTempIntegratedConsole { get ; private set ; }
@@ -118,6 +118,17 @@ protected Task LaunchScript(RequestContext<object> requestContext)
118
118
119
119
private async Task OnExecutionCompleted ( Task executeTask )
120
120
{
121
+ try
122
+ {
123
+ await executeTask ;
124
+ }
125
+ catch ( Exception e )
126
+ {
127
+ Logger . Write (
128
+ LogLevel . Error ,
129
+ "Exception occurred while awaiting debug launch task.\n \n " + e . ToString ( ) ) ;
130
+ }
131
+
121
132
Logger . Write ( LogLevel . Verbose , "Execution completed, terminating..." ) ;
122
133
123
134
this . executionCompleted = true ;
@@ -471,7 +482,7 @@ protected async Task HandleDisconnectRequest(
471
482
if ( this . executionCompleted == false )
472
483
{
473
484
this . disconnectRequestContext = requestContext ;
474
- this . editorSession . PowerShellContext . AbortExecution ( ) ;
485
+ this . editorSession . PowerShellContext . AbortExecution ( shouldAbortDebugSession : true ) ;
475
486
476
487
if ( this . isInteractiveDebugSession )
477
488
{
@@ -506,7 +517,7 @@ protected async Task HandleSetBreakpointsRequest(
506
517
}
507
518
}
508
519
catch ( Exception e ) when (
509
- e is FileNotFoundException ||
520
+ e is FileNotFoundException ||
510
521
e is DirectoryNotFoundException ||
511
522
e is IOException ||
512
523
e is NotSupportedException ||
@@ -653,7 +664,7 @@ protected async Task HandleSetExceptionBreakpointsRequest(
653
664
RequestContext < object > requestContext )
654
665
{
655
666
// TODO: When support for exception breakpoints (unhandled and/or first chance)
656
- // are added to the PowerShell engine, wire up the VSCode exception
667
+ // are added to the PowerShell engine, wire up the VSCode exception
657
668
// breakpoints here using the pattern below to prevent bug regressions.
658
669
//if (!this.noDebug)
659
670
//{
@@ -756,6 +767,20 @@ protected async Task HandleStackTraceRequest(
756
767
StackFrameDetails [ ] stackFrames =
757
768
editorSession . DebugService . GetStackFrames ( ) ;
758
769
770
+ // Handle a rare race condition where the adapter requests stack frames before they've
771
+ // begun building.
772
+ if ( stackFrames == null )
773
+ {
774
+ await requestContext . SendResult (
775
+ new StackTraceResponseBody
776
+ {
777
+ StackFrames = new StackFrame [ 0 ] ,
778
+ TotalFrames = 0
779
+ } ) ;
780
+
781
+ return ;
782
+ }
783
+
759
784
List < StackFrame > newStackFrames = new List < StackFrame > ( ) ;
760
785
761
786
int startFrameIndex = stackTraceParams . StartFrame ?? 0 ;
@@ -779,8 +804,7 @@ protected async Task HandleStackTraceRequest(
779
804
i ) ) ;
780
805
}
781
806
782
- await requestContext . SendResult (
783
- new StackTraceResponseBody
807
+ await requestContext . SendResult ( new StackTraceResponseBody
784
808
{
785
809
StackFrames = newStackFrames . ToArray ( ) ,
786
810
TotalFrames = newStackFrames . Count
0 commit comments