From 51388139356efa700f9dd4616e822eb377a47c95 Mon Sep 17 00:00:00 2001 From: arath17 <41408618+arath17@users.noreply.github.com> Date: Thu, 8 Jun 2023 05:26:21 +0530 Subject: [PATCH] Use start returned from _attemptOperation in extend() (#276) * Fix extension failure * format * Use start returned from _attemptOperation in extend() for calculating expiration time --------- Co-authored-by: Ashutosh Rath --- src/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index b652ef8..660de59 100644 --- a/src/index.ts +++ b/src/index.ts @@ -375,14 +375,12 @@ export default class Redlock extends EventEmitter { throw new Error("Duration must be an integer value in milliseconds."); } - const start = Date.now(); - // The lock has already expired. if (existing.expiration < Date.now()) { throw new ExecutionError("Cannot extend an already-expired lock.", []); } - const { attempts } = await this._execute( + const { attempts, start } = await this._execute( this.scripts.extendScript, existing.resources, [existing.value, duration],