@@ -13,12 +13,9 @@ export const kLaunch = Symbol('kLaunch')
1313
1414export class AppProcess {
1515 private io ?: ChildProcess
16- private controller : AbortController
1716 private [ kUrl ] ?: URL
1817
19- constructor ( protected readonly options : AppProcessOptions ) {
20- this . controller = new AbortController ( )
21- }
18+ constructor ( protected readonly options : AppProcessOptions ) { }
2219
2320 get url ( ) : URL {
2421 const url = this [ kUrl ]
@@ -44,7 +41,6 @@ export class AppProcess {
4441 )
4542
4643 this . io = spawn ( command , args , {
47- signal : this . controller . signal ,
4844 cwd : this . options . cwd ,
4945 env : {
5046 ...process . env ,
@@ -65,18 +61,14 @@ export class AppProcess {
6561 * Stop the running application.
6662 */
6763 public async dispose ( ) : Promise < void > {
68- invariant (
69- ! this . controller . signal . aborted ,
70- 'Failed to dispose of a launched application: already disposed' ,
71- )
72-
7364 invariant (
7465 this . io != null ,
7566 'Failed to dispose of a launched application: application is not running. Did you forget to run `await launcher.run()`?' ,
7667 )
7768
69+ // The application has been exited by other means (e.g. unhandled exception).
7870 if ( this . io . exitCode !== null ) {
79- return Promise . resolve ( )
71+ return
8072 }
8173
8274 const exitPromise = new DeferredPromise < void > ( )
@@ -90,7 +82,10 @@ export class AppProcess {
9082 exitPromise . reject ( new Error ( `Process exited with code ${ exitCode } ` ) )
9183 } )
9284
93- this . controller . abort ( )
85+ if ( ! this . io . kill ( 'SIGTERM' ) ) {
86+ exitPromise . reject ( 'SIGTERM did not succeed' )
87+ }
88+
9489 await exitPromise
9590 }
9691
0 commit comments