Skip to content

Commit

Permalink
Use start returned from _attemptOperation in extend() (#276)
Browse files Browse the repository at this point in the history
* Fix extension failure

* format

* Use start returned from _attemptOperation in extend() for calculating expiration time

---------

Co-authored-by: Ashutosh Rath <arath9@its.jnj.com>
  • Loading branch information
arath17 and Ashutosh Rath authored Jun 7, 2023
1 parent 06d9f5c commit 5138813
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 5138813

Please sign in to comment.