Skip to content

Commit 6674c58

Browse files
committed
Fixed race condition
1 parent 8874e17 commit 6674c58

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

internal-packages/run-engine/src/engine/locking.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ export class RunLocker {
9393
this.automaticExtensionThreshold = options.automaticExtensionThreshold ?? 500;
9494

9595
this.redlock = new Redlock([options.redis], {
96-
driftFactor: 0.01,
9796
retryCount: 0, // Disable Redlock's internal retrying - we handle retries ourselves
98-
retryDelay: 200, // Not used since retryCount = 0
99-
retryJitter: 200, // Not used since retryCount = 0
100-
automaticExtensionThreshold: this.automaticExtensionThreshold,
10197
});
10298
this.asyncLocalStorage = new AsyncLocalStorage<LockContext>();
10399
this.logger = options.logger;
@@ -428,6 +424,11 @@ export class RunLocker {
428424
controller: AbortController,
429425
scheduleNext: () => void
430426
): Promise<void> {
427+
// Check if cleanup has started before proceeding
428+
if (context.timeout === null) {
429+
return;
430+
}
431+
431432
context.timeout = undefined;
432433

433434
const [error, newLock] = await tryCatch(context.lock.extend(duration));

0 commit comments

Comments
 (0)