@@ -16,9 +16,6 @@ export const application = (
1616 const logger = createLogger ( { prefix : `${ appDirName } ` } ) ;
1717 const state = { completedSetup : false , serverUrl : '' , env : { } as EnvironmentConfig } ;
1818 const cleanupFns : { ( ) : unknown } [ ] = [ ] ;
19- const now = Date . now ( ) ;
20- const stdoutFilePath = path . resolve ( appDirPath , `e2e.${ now } .log` ) ;
21- const stderrFilePath = path . resolve ( appDirPath , `e2e.${ now } .err.log` ) ;
2219 let buildOutput = '' ;
2320 let serveOutput = '' ;
2421
@@ -68,16 +65,32 @@ export const application = (
6865 return { port, serverUrl : runtimeServerUrl } ;
6966 }
7067
68+ // Always log to console so we can see what's happening
69+ const logOutput = ( prefix : string ) => ( chunk : Buffer ) => {
70+ const lines = chunk . toString ( ) . trim ( ) . split ( '\n' ) ;
71+ lines . forEach ( line => console . log ( `[${ appDirName } ] ${ prefix } : ${ line } ` ) ) ;
72+ } ;
73+
7174 const proc = run ( scripts . dev , {
7275 cwd : appDirPath ,
7376 env : { PORT : port . toString ( ) } ,
7477 detached : opts . detached ,
75- stdout : opts . detached ? fs . openSync ( stdoutFilePath , 'a' ) : undefined ,
76- stderr : opts . detached ? fs . openSync ( stderrFilePath , 'a' ) : undefined ,
77- log : opts . detached ? undefined : log ,
7878 } ) ;
7979
80- const shouldExit = ( ) => ! ! proc . exitCode && proc . exitCode !== 0 ;
80+ // Stream stdout/stderr to console
81+ proc . stdout ?. on ( 'data' , logOutput ( 'stdout' ) ) ;
82+ proc . stderr ?. on ( 'data' , logOutput ( 'stderr' ) ) ;
83+
84+ console . log ( `[${ appDirName } ] Process spawned with pid: ${ proc . pid } , detached: ${ opts . detached } ` ) ;
85+
86+ const shouldExit = ( ) => {
87+ if ( proc . exitCode !== null && proc . exitCode !== 0 ) {
88+ console . log ( `[${ appDirName } ] Process exited with code: ${ proc . exitCode } ` ) ;
89+ return true ;
90+ }
91+ return false ;
92+ } ;
93+
8194 await waitForServer ( runtimeServerUrl , { log, maxAttempts : Infinity , shouldExit } ) ;
8295 log ( `Server started at ${ runtimeServerUrl } , pid: ${ proc . pid } ` ) ;
8396 cleanupFns . push ( ( ) => awaitableTreekill ( proc . pid , 'SIGKILL' ) ) ;
0 commit comments