@@ -78,6 +78,7 @@ const retainCleanupOwnership = (profile: ContainerProfile, detail: string, regis
7878 timer = undefined ;
7979 complete = true ;
8080 if ( active . get ( invocation . attemptId ) === handle ) active . delete ( invocation . attemptId ) ;
81+ activeProfiles . delete ( profile ) ;
8182 cleanupRecoveries . delete ( handle ) ;
8283 resolveSettled ( Object . freeze ( { attemptId : invocation . attemptId , context : invocation . context ,
8384 exitCode : null , signal : null , stopReason : 'capture-failure' , stdout : '' ,
@@ -91,6 +92,7 @@ const retainCleanupOwnership = (profile: ContainerProfile, detail: string, regis
9192 } ;
9293 handle = Object . freeze ( { attemptId : invocation . attemptId , settled,
9394 cancel : ( ) => { if ( timer ) clearTimeout ( timer ) ; timer = undefined ; retry ( ) ; } } ) ;
95+ activeProfiles . add ( profile ) ;
9496 if ( register ) active . set ( invocation . attemptId , handle ) ;
9597 else cleanupRecoveries . add ( handle ) ;
9698 schedule ( ) ;
@@ -399,8 +401,9 @@ export function startProfileInvocation(profile: ContainerProfile, options: Super
399401 decodedOutput = decoded ;
400402 } catch ( error ) {
401403 const message = error instanceof Error ? error . message : String ( error ) ;
402- const reason = error instanceof OutputLimitError || / e x c e e d s i t s c a p t u r e l i m i t / i. test ( message )
403- ? 'output-limit' : error instanceof CaptureDeadlineError ? 'timeout' : 'capture-failure' ;
404+ const reason : StopReason = stopReason ?? ( performance . now ( ) >= deadline ? 'timeout'
405+ : error instanceof OutputLimitError || / e x c e e d s i t s c a p t u r e l i m i t / i. test ( message )
406+ ? 'output-limit' : error instanceof CaptureDeadlineError ? 'timeout' : 'capture-failure' ) ;
404407 failureDetail ??= message ;
405408 if ( closed ) stopReason ??= reason ;
406409 else stop ( reason ) ;
0 commit comments