From 0fd0efb98dcb622cf3aeecc6ee7c9de04ecb7b26 Mon Sep 17 00:00:00 2001 From: Tithra Chap Date: Thu, 6 Feb 2025 09:36:19 +1000 Subject: [PATCH] prevent infinite collection of attempts --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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") {