diff --git a/src/index.ts b/src/index.ts index 660de59..e7a1152 100644 --- a/src/index.ts +++ b/src/index.ts @@ -440,7 +440,8 @@ export default class Redlock extends EventEmitter { args ); - attempts.push(stats); + // Infinite retry may result in memory leak when routine() is on hold for long time + if (maxAttempts !== Infinity) attempts.push(stats); // The operation achieved a quorum in favor. if (vote === "for") {