From bf49390969ce7a3761b9540e76aebcfb4d29f386 Mon Sep 17 00:00:00 2001 From: Niels Kootstra <545768+nkootstra@users.noreply.github.com> Date: Thu, 10 Sep 2026 04:46:00 +0200 Subject: [PATCH] fix(compat): avoid CloudWatch statistics time race (#3320) --- compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts b/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts index f3820dd3f9..309c8720e2 100644 --- a/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts +++ b/compatibility-tests/sdk-test-node/tests/cloudwatch.test.ts @@ -77,8 +77,7 @@ describe('CloudWatch Metrics', () => { }); it('should put metric data with statistic values', async () => { - const now = new Date(); - const start = new Date(now.getTime() - 3600000); + const start = new Date(Date.now() - 3600000); // Put metric data with pre-calculated statistics await cw.send( @@ -100,12 +99,13 @@ describe('CloudWatch Metrics', () => { ); // Query back the statistics + const end = new Date(); const response = await cw.send( new GetMetricStatisticsCommand({ Namespace: namespace, MetricName: 'AggregatedMetric', StartTime: start, - EndTime: now, + EndTime: end, Period: 3600, Statistics: ['Sum', 'Average', 'Minimum', 'Maximum', 'SampleCount'], })