Skip to content

Commit 301c0e4

Browse files
committed
fix(server): ensure fatal startup logs are captured before exit
Replaces the asynchronous `log.severe` call in the main catch block with a direct, synchronous write to `stderr`, followed by `stderr.flush()`. This fixes a race condition where the process could exit before the logger had a chance to write the fatal error message, ensuring that critical startup failure information is never lost.
1 parent a588d98 commit 301c0e4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

bin/main.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ Future<void> main(List<String> args) async {
8282
);
8383
} catch (e, s) {
8484
log.severe('EAGER_INIT: FATAL: Failed to start server.', e, s);
85+
// Log directly to stderr and flush to ensure the message is captured
86+
// before the process exits, which is crucial for debugging startup errors.
87+
stderr.writeln('EAGER_INIT: FATAL: Failed to start server. Error: $e\nStack Trace: $s');
88+
await stderr.flush();
8589
// Exit the process if initialization fails.
8690
exit(1);
8791
}

0 commit comments

Comments
 (0)