From 4362b8f8021594999e6947efc9e9fd3b0372ac79 Mon Sep 17 00:00:00 2001 From: Daniel Werner Date: Thu, 26 Dec 2024 10:35:21 -0800 Subject: [PATCH] common: fix sequentialTimerX log line to warn if configured time took longer than configured --- .../indexer-common/src/sequential-timer.ts | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/indexer-common/src/sequential-timer.ts b/packages/indexer-common/src/sequential-timer.ts index 700595ab1..53b2d2cf8 100644 --- a/packages/indexer-common/src/sequential-timer.ts +++ b/packages/indexer-common/src/sequential-timer.ts @@ -52,18 +52,14 @@ export function sequentialTimerReduce( function work() { const workStarted = Date.now() const promiseOrT = reducer(acc, workStarted) - const workEnded = Date.now() const loopTime = workStarted - lastWorkStarted - const workTime = workEnded - workStarted - logger.debug( - `sequentialTimerReduce loop took ${loopTime}ms, work took ${workTime}ms caller(${caller})`, - ) + logger.debug(`sequentialTimerReduce loop took ${loopTime}ms caller(${caller})`) - if (workTime > milliseconds) { + if (loopTime > milliseconds) { logger.warn( 'sequentialTimerReduce work took longer than the sequential timer was configured for', { - workTime, + loopTime, milliseconds, }, ) @@ -124,18 +120,14 @@ export function sequentialTimerMap( function work() { const workStarted = Date.now() const promiseOrU = mapper(Date.now()) - const workEnded = Date.now() const loopTime = workStarted - lastWorkStarted - const workTime = workEnded - workStarted - logger.debug( - `sequentialTimerMap loop took ${loopTime}ms, work took ${workTime}ms caller(${caller})`, - ) + logger.debug(`sequentialTimerMap loop took ${loopTime}ms caller(${caller})`) - if (workTime > milliseconds) { + if (loopTime > milliseconds) { logger.warn( 'sequentialTimerMap work took longer than the sequential timer was configured for', { - workTime, + loopTime, milliseconds, }, )