File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,15 @@ export class LambdaDogStatsD {
7878 /** Block until all in-flight sends have settled */
7979 public async flush ( ) : Promise < void > {
8080 const allSettled = Promise . allSettled ( this . pendingSends ) ;
81- const maxTimeout = new Promise ( ( resolve ) => setTimeout ( resolve , LambdaDogStatsD . MAX_FLUSH_TIMEOUT ) ) ;
81+ const maxTimeout = new Promise < "timeout" > ( ( resolve ) => {
82+ setTimeout ( ( ) => resolve ( "timeout" ) , LambdaDogStatsD . MAX_FLUSH_TIMEOUT ) ;
83+ } ) ;
84+
85+ const winner = await Promise . race ( [ allSettled , maxTimeout ] ) ;
86+ if ( winner === "timeout" ) {
87+ logDebug ( "Timed out before sending all metric payloads" ) ;
88+ }
8289
83- await Promise . race ( [ allSettled , maxTimeout ] ) ;
8490 this . pendingSends . clear ( ) ;
8591 }
8692}
You can’t perform that action at this time.
0 commit comments