@@ -178,16 +178,6 @@ export class BackendProcessExitStatusError extends Schema.TaggedError<BackendPro
178178 }
179179}
180180
181- // Node reports no exit code for a child killed by a signal, so Effect's
182- // spawner fails `exitCode` and leaves the signal name only in the cause's
183- // message. Returns that signal, or undefined for a genuine read failure.
184- const SIGNAL_EXIT_PATTERN = / r e c e i p t o f s i g n a l : ' ( S I G [ A - Z 0 - 9 ] + ) ' / ;
185- function signalFromExitCodeFailure ( error : PlatformError . PlatformError ) : string | undefined {
186- return error . cause instanceof Error
187- ? SIGNAL_EXIT_PATTERN . exec ( error . cause . message ) ?. [ 1 ]
188- : undefined ;
189- }
190-
191181export const BackendProcessError = Schema . Union ( [
192182 BackendProcessBootstrapEncodeError ,
193183 BackendProcessSpawnError ,
@@ -578,27 +568,31 @@ export const runBackendProcess = Effect.fn("runBackendProcess")(function* (
578568 yield * probeReadiness ( ) . pipe ( Effect . repeat ( { while : ( ready ) => ! ready } ) , Effect . forkScoped ) ;
579569
580570 const exit = yield * handle . exitCode . pipe (
581- Effect . map ( ( exitCode ) : BackendProcessExit => ( {
571+ Effect . map ( ( exitCode ) => ( {
582572 code : Option . some ( exitCode ) ,
583573 reason : `code=${ exitCode } ` ,
584574 } ) ) ,
585575 Effect . catch ( ( cause ) => {
586- const signal = signalFromExitCodeFailure ( cause ) ;
587- return signal === undefined
588- ? Effect . fail (
589- new BackendProcessExitStatusError ( {
590- executablePath : options . executablePath ,
591- entryPath : options . entryPath ,
592- cwd : options . cwd ,
593- httpBaseUrl : options . httpBaseUrl ,
594- pid : Number ( handle . pid ) ,
595- cause,
596- } ) ,
597- )
598- : Effect . succeed < BackendProcessExit > ( {
599- code : Option . none ( ) ,
600- reason : `killed by ${ signal } ` ,
601- } ) ;
576+ // Effect's Node spawner exposes signal exits only through this cause message.
577+ const signal =
578+ cause . cause instanceof Error
579+ ? / ^ P r o c e s s i n t e r r u p t e d d u e t o r e c e i p t o f s i g n a l : ' ( S I G [ A - Z 0 - 9 ] + ) ' $ / . exec (
580+ cause . cause . message ,
581+ ) ?. [ 1 ]
582+ : undefined ;
583+ if ( signal !== undefined ) {
584+ return Effect . succeed ( { code : Option . none ( ) , reason : `killed by ${ signal } ` } ) ;
585+ }
586+ return Effect . fail (
587+ new BackendProcessExitStatusError ( {
588+ executablePath : options . executablePath ,
589+ entryPath : options . entryPath ,
590+ cwd : options . cwd ,
591+ httpBaseUrl : options . httpBaseUrl ,
592+ pid : Number ( handle . pid ) ,
593+ cause,
594+ } ) ,
595+ ) ;
602596 } ) ,
603597 Effect . exit ,
604598 ) ;
0 commit comments