File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -125,13 +125,17 @@ function validateSatelliteName(name: string | undefined, logger?: any): void {
125125
126126export async function createServer ( ) {
127127 // Add global error handlers to catch unhandled errors
128+ // Note: These run before Fastify logger is initialized, so we write to stderr directly
128129 process . on ( 'unhandledRejection' , ( reason , promise ) => {
129- console . error ( 'Unhandled Rejection at:' , promise , 'reason:' , reason ) ;
130+ const errorMessage = reason instanceof Error ? reason . message : String ( reason ) ;
131+ process . stderr . write ( `FATAL: Unhandled Rejection at: ${ String ( promise ) } reason: ${ errorMessage } \n` ) ;
130132 process . exit ( 1 ) ;
131133 } ) ;
132134
133135 process . on ( 'uncaughtException' , ( error ) => {
134- console . error ( 'Uncaught Exception:' , error ) ;
136+ const errorMessage = error instanceof Error ? error . message : String ( error ) ;
137+ const errorStack = error instanceof Error ? error . stack : '' ;
138+ process . stderr . write ( `FATAL: Uncaught Exception: ${ errorMessage } \n${ errorStack || '' } \n` ) ;
135139 process . exit ( 1 ) ;
136140 } ) ;
137141
You can’t perform that action at this time.
0 commit comments