@@ -31,6 +31,7 @@ import {
3131 forwardSignalToVitestProcessGroup ,
3232 installVitestProcessGroupCleanup ,
3333 shouldUseDetachedVitestProcessGroup ,
34+ terminateVitestProcessGroupForTimeout ,
3435} from "./vitest-process-group.mts" ;
3536
3637type VitestFs = {
@@ -1067,7 +1068,6 @@ export function installVitestNoOutputWatchdog(params: {
10671068 streams ?: Array < WatchdogStream | null > ;
10681069 timeoutMs : number | null ;
10691070 heartbeatMs ?: number | null ;
1070- label ?: string ;
10711071 forceKillAfterMs ?: number ;
10721072 log ?: ( message : string ) => void ;
10731073 onTimeout ?: ( ) => void ;
@@ -1089,8 +1089,6 @@ export function installVitestNoOutputWatchdog(params: {
10891089 : null ;
10901090 const streams =
10911091 params . streams ?. filter ( ( stream ) : stream is WatchdogStream => stream !== null ) ?? [ ] ;
1092- const label = params . label ?. trim ( ) ;
1093- const suffix = label ? ` (${ label } )` : "" ;
10941092
10951093 let active = true ;
10961094 let silenceTimer : ReturnType < typeof setTimeout > | null = null ;
@@ -1130,7 +1128,7 @@ export function installVitestNoOutputWatchdog(params: {
11301128 return ;
11311129 }
11321130 silentForMs += heartbeatMs ;
1133- params . log ?.( `[vitest] still running with no output for ${ silentForMs } ms${ suffix } .` ) ;
1131+ params . log ?.( `[vitest] still running with no output for ${ silentForMs } ms.` ) ;
11341132 if ( silentForMs + heartbeatMs < timeoutMs ) {
11351133 scheduleHeartbeatTimer ( ) ;
11361134 }
@@ -1151,21 +1149,21 @@ export function installVitestNoOutputWatchdog(params: {
11511149 clearHeartbeatTimer ( ) ;
11521150 timedOut = true ;
11531151 params . log ?.(
1154- `[vitest] no output for ${ timeoutMs } ms; terminating stalled Vitest process group${ suffix } .` ,
1152+ `[vitest] no output for ${ timeoutMs } ms; terminating stalled Vitest process group.` ,
11551153 ) ;
1156- params . onTimeout ?.( ) ;
11571154 if ( forceKillAfterMs > 0 ) {
11581155 clearForceKillTimer ( ) ;
11591156 forceKillTimer = setTimeoutFn ( ( ) => {
11601157 if ( ! active ) {
11611158 return ;
11621159 }
11631160 params . log ?.(
1164- `[vitest] process group still alive after ${ forceKillAfterMs } ms; sending SIGKILL${ suffix } .` ,
1161+ `[vitest] process group still alive after ${ forceKillAfterMs } ms; sending SIGKILL.` ,
11651162 ) ;
11661163 params . onForceKill ?.( ) ;
11671164 } , forceKillAfterMs ) ;
11681165 }
1166+ params . onTimeout ?.( ) ;
11691167 } , timeoutMs ) ;
11701168 } ;
11711169
@@ -1252,16 +1250,15 @@ export function spawnWatchedVitestProcess({
12521250 pnpmArgs,
12531251 spawnParams,
12541252 env,
1255- label,
12561253 onNoOutputTimeout,
12571254} : {
12581255 pnpmArgs : string [ ] ;
12591256 spawnParams : PnpmRunnerParams ;
12601257 env : NodeJS . ProcessEnv ;
1261- label ?: string ;
12621258 onNoOutputTimeout ?: ( ) => void ;
12631259} ) {
12641260 let forwardedSignal : NodeSignal | null = null ;
1261+ let diagnosticsCompletion : Promise < void > | null = null ;
12651262 const child = spawnVitestProcess ( {
12661263 pnpmArgs,
12671264 spawnParams,
@@ -1278,17 +1275,19 @@ export function spawnWatchedVitestProcess({
12781275 streams : [ child . stdout , child . stderr ] ,
12791276 timeoutMs : resolveVitestNoOutputTimeoutMs ( env ) ,
12801277 heartbeatMs : resolveVitestNoOutputHeartbeatMs ( env ) ,
1281- label,
12821278 log : ( message ) => {
12831279 console . error ( message ) ;
12841280 } ,
12851281 onTimeout : ( ) => {
1286- onNoOutputTimeout ?.( ) ;
1287- forwardSignalToVitestProcessGroup ( {
1282+ const termination = terminateVitestProcessGroupForTimeout ( {
12881283 child,
1289- signal : "SIGTERM" ,
12901284 kill : process . kill . bind ( process ) ,
1285+ log : ( message ) => {
1286+ console . error ( message ) ;
1287+ } ,
1288+ onTimeout : onNoOutputTimeout ,
12911289 } ) ;
1290+ diagnosticsCompletion = termination . diagnostics ;
12921291 } ,
12931292 onForceKill : ( ) => {
12941293 forwardSignalToVitestProcessGroup ( {
@@ -1320,7 +1319,8 @@ export function spawnWatchedVitestProcess({
13201319 } ) ,
13211320 forwardedOutput ,
13221321 ] )
1323- . then ( ( [ { code, signal } ] ) => {
1322+ . then ( async ( [ { code, signal } ] ) => {
1323+ await diagnosticsCompletion ;
13241324 const result = unhandledErrors . finish ( ) ;
13251325 if ( result ) {
13261326 writeVitestUnhandledErrorSummary ( result , env ) ;
@@ -1412,7 +1412,6 @@ async function main(
14121412 ] ,
14131413 spawnParams : resolveVitestSpawnParams ( spawnEnv ) ,
14141414 env : spawnEnv ,
1415- label : guardedVitestArgs . join ( " " ) ,
14161415 } ) ,
14171416 ) ;
14181417 if ( exitCode !== 0 ) {
0 commit comments