@@ -472,7 +472,34 @@ const zodIpc = new ZodIpcConnection({
472
472
async function flushAll ( timeoutInMs : number = 10_000 ) {
473
473
const now = performance . now ( ) ;
474
474
475
- await Promise . all ( [ flushTracingSDK ( timeoutInMs ) , flushMetadata ( timeoutInMs ) ] ) ;
475
+ const results = await Promise . allSettled ( [
476
+ flushTracingSDK ( timeoutInMs ) ,
477
+ flushMetadata ( timeoutInMs ) ,
478
+ ] ) ;
479
+
480
+ const successfulFlushes = results
481
+ . filter ( ( result ) => result . status === "fulfilled" )
482
+ . map ( ( result ) => result . value . flushed ) ;
483
+
484
+ const failedFlushes = [ "tracingSDK" , "runMetadata" ] . filter (
485
+ ( flushed ) => ! successfulFlushes . includes ( flushed )
486
+ ) ;
487
+
488
+ if ( failedFlushes . length > 0 ) {
489
+ logError ( `Failed to flush ${ failedFlushes . join ( ", " ) } ` ) ;
490
+ }
491
+
492
+ const errorMessages = results
493
+ . filter ( ( result ) => result . status === "rejected" )
494
+ . map ( ( result ) => result . reason ) ;
495
+
496
+ if ( errorMessages . length > 0 ) {
497
+ logError ( errorMessages . join ( "\n" ) ) ;
498
+ }
499
+
500
+ for ( const flushed of successfulFlushes ) {
501
+ log ( `Flushed ${ flushed } successfully` ) ;
502
+ }
476
503
477
504
const duration = performance . now ( ) - now ;
478
505
@@ -487,6 +514,11 @@ async function flushTracingSDK(timeoutInMs: number = 10_000) {
487
514
const duration = performance . now ( ) - now ;
488
515
489
516
log ( `Flushed tracingSDK in ${ duration } ms` ) ;
517
+
518
+ return {
519
+ flushed : "tracingSDK" ,
520
+ durationMs : duration ,
521
+ } ;
490
522
}
491
523
492
524
async function flushMetadata ( timeoutInMs : number = 10_000 ) {
@@ -497,6 +529,11 @@ async function flushMetadata(timeoutInMs: number = 10_000) {
497
529
const duration = performance . now ( ) - now ;
498
530
499
531
log ( `Flushed runMetadata in ${ duration } ms` ) ;
532
+
533
+ return {
534
+ flushed : "runMetadata" ,
535
+ durationMs : duration ,
536
+ } ;
500
537
}
501
538
502
539
const managedWorkerRuntime = new ManagedRuntimeManager ( zodIpc , showInternalLogs ) ;
0 commit comments