From 5c4df89e95a68aef65b2d153a16687a4635115b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ad=C3=A1mek?= Date: Tue, 26 Jul 2022 11:57:55 +0200 Subject: [PATCH] chore: do not log initial state of `AutoscaledPool` It's always empty, no need to log that. --- packages/core/src/autoscaling/autoscaled_pool.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/autoscaling/autoscaled_pool.ts b/packages/core/src/autoscaling/autoscaled_pool.ts index 01e37e9bc7db..d1313e186703 100644 --- a/packages/core/src/autoscaling/autoscaled_pool.ts +++ b/packages/core/src/autoscaling/autoscaled_pool.ts @@ -196,7 +196,7 @@ export class AutoscaledPool { private _desiredConcurrency: number; private _currentConcurrency = 0; private isStopped = false; - private lastLoggingTime = 0; + private lastLoggingTime?: number; private resolve: ((val?: unknown) => void) | null = null; private reject: ((reason?: unknown) => void) | null = null; private snapshotter: Snapshotter; @@ -274,7 +274,6 @@ export class AutoscaledPool { this._desiredConcurrency = desiredConcurrency ?? minConcurrency; this._currentConcurrency = 0; this.isStopped = false; - this.lastLoggingTime = 0; this.resolve = null; this.reject = null; this._autoscale = this._autoscale.bind(this); @@ -592,7 +591,10 @@ export class AutoscaledPool { // On periodic intervals, print comprehensive log information if (this.loggingIntervalMillis > 0) { const now = Date.now(); - if (now > this.lastLoggingTime + this.loggingIntervalMillis) { + + if (this.lastLoggingTime == null) { + this.lastLoggingTime = now; + } else if (now > this.lastLoggingTime + this.loggingIntervalMillis) { this.lastLoggingTime = now; this.log.info('state', { currentConcurrency: this._currentConcurrency,