File tree Expand file tree Collapse file tree
src/client/testing/testController/common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,8 +102,27 @@ export async function startRunResultNamedPipe(
102102 if ( cancellationToken ) {
103103 disposables . push (
104104 cancellationToken ?. onCancellationRequested ( ( ) => {
105- traceLog ( `Test Result named pipe ${ pipeName } cancelled` ) ;
106- disposable . dispose ( ) ;
105+ traceLog (
106+ `Test Result named pipe ${ pipeName } cancelled; draining buffered data before dispose` ,
107+ ) ;
108+ // Do NOT dispose the reader immediately. In the debug path, cancellation
109+ // fires as soon as the debug session terminates, but the result pipe may
110+ // still have buffered messages that have not been delivered to the
111+ // `reader.listen` callback yet. Disposing now would close the reader and
112+ // drop those pending results.
113+ //
114+ // The reader's `onClose` event (registered below) will fire once the
115+ // subprocess closes its end of the pipe and all buffered data has been
116+ // drained, and that handler will dispose. Use a safety timeout to force
117+ // disposal in case the pipe never closes naturally (e.g. subprocess hang).
118+ setTimeout ( ( ) => {
119+ if ( disposables . length > 0 ) {
120+ traceVerbose (
121+ `Test Result named pipe ${ pipeName } drain timeout, forcing dispose` ,
122+ ) ;
123+ disposable . dispose ( ) ;
124+ }
125+ } , 5000 ) ;
107126 } ) ,
108127 ) ;
109128 }
You can’t perform that action at this time.
0 commit comments