@@ -76,16 +76,26 @@ export async function handleLog(logger: Logger, message: string, options: LogOpt
76
76
// Ensure all writes are flushed to disk
77
77
await targetLogger . flushPendingWrites ( )
78
78
79
- // Verify the log file exists and has content
79
+ // Get the current log file path
80
80
const logFile = targetLogger . getCurrentLogFilePath ( )
81
81
console . error ( 'Debug: Verifying log file:' , logFile )
82
82
83
+ // Wait a short time to ensure file system has caught up
84
+ await new Promise ( resolve => setTimeout ( resolve , 100 ) )
85
+
86
+ // Verify the log file exists and has content
83
87
const { stat } = await import ( 'node:fs/promises' )
84
- const stats = await stat ( logFile )
85
- console . error ( 'Debug: Log file stats:' , { size : stats . size , path : logFile } )
88
+ try {
89
+ const stats = await stat ( logFile )
90
+ console . error ( 'Debug: Log file stats:' , { size : stats . size , path : logFile } )
86
91
87
- if ( stats . size === 0 ) {
88
- throw new Error ( 'Log file exists but is empty after write' )
92
+ if ( stats . size === 0 ) {
93
+ throw new Error ( 'Log file exists but is empty after write' )
94
+ }
95
+ }
96
+ catch ( err ) {
97
+ console . error ( 'Debug: Error verifying log file:' , err )
98
+ throw new Error ( `Failed to verify log file at ${ logFile } : ${ err } ` )
89
99
}
90
100
91
101
console . error ( 'Debug: Log operation completed successfully' )
0 commit comments