File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -360,17 +360,34 @@ export class ServiceScriptExecution extends BaseExecutionWithCommand<ServiceScri
360360 void this . abort ( ) ;
361361 } ) ;
362362
363+ const adoptee = this . #state. adoptee ;
364+ // If any dependency has cascade:true, stop the adoptee before running
365+ // deps so they can freely write to files the service may have open.
366+ const shouldStopAdopteeEarly =
367+ adoptee !== undefined &&
368+ this . _config . dependencies . some ( ( dep ) => dep . cascade ) ;
369+
363370 this . #state = {
364371 id : 'executingDeps' ,
365372 deferredFingerprint : new Deferred ( ) ,
366- adoptee : this . #state . adoptee ,
373+ adoptee : shouldStopAdopteeEarly ? undefined : adoptee ,
367374 } ;
368- void this . _executeDependencies ( ) . then ( ( result ) => {
369- if ( result . ok ) {
370- this . #onDepsExecuted( result . value ) ;
371- } else {
372- this . #onDepExecErr( result ) ;
375+
376+ void ( shouldStopAdopteeEarly
377+ ? adoptee . abort ( )
378+ : Promise . resolve ( )
379+ ) . then ( ( ) => {
380+ if ( this . #state. id !== 'executingDeps' ) {
381+ // Service was aborted while waiting for the adoptee to stop.
382+ return ;
373383 }
384+ void this . _executeDependencies ( ) . then ( ( result ) => {
385+ if ( result . ok ) {
386+ this . #onDepsExecuted( result . value ) ;
387+ } else {
388+ this . #onDepExecErr( result ) ;
389+ }
390+ } ) ;
374391 } ) ;
375392 return this . #state. deferredFingerprint . promise ;
376393 }
You can’t perform that action at this time.
0 commit comments