@@ -472,7 +472,34 @@ const zodIpc = new ZodIpcConnection({
472472async function flushAll ( timeoutInMs : number = 10_000 ) {
473473 const now = performance . now ( ) ;
474474
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+ }
476503
477504 const duration = performance . now ( ) - now ;
478505
@@ -487,6 +514,11 @@ async function flushTracingSDK(timeoutInMs: number = 10_000) {
487514 const duration = performance . now ( ) - now ;
488515
489516 log ( `Flushed tracingSDK in ${ duration } ms` ) ;
517+
518+ return {
519+ flushed : "tracingSDK" ,
520+ durationMs : duration ,
521+ } ;
490522}
491523
492524async function flushMetadata ( timeoutInMs : number = 10_000 ) {
@@ -497,6 +529,11 @@ async function flushMetadata(timeoutInMs: number = 10_000) {
497529 const duration = performance . now ( ) - now ;
498530
499531 log ( `Flushed runMetadata in ${ duration } ms` ) ;
532+
533+ return {
534+ flushed : "runMetadata" ,
535+ durationMs : duration ,
536+ } ;
500537}
501538
502539const managedWorkerRuntime = new ManagedRuntimeManager ( zodIpc , showInternalLogs ) ;
0 commit comments