File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
internal-packages/run-engine/src/engine Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ export class RunLocker {
213
213
let totalWaitTime = 0 ;
214
214
215
215
// Retry the lock acquisition with exponential backoff
216
- let lock : redlock . Lock ;
216
+ let lock : redlock . Lock | undefined ;
217
217
let lastError : Error | undefined ;
218
218
219
219
for ( let attempt = 0 ; attempt <= maxRetries ; attempt ++ ) {
@@ -315,6 +315,23 @@ export class RunLocker {
315
315
throw lastError ;
316
316
}
317
317
318
+ // Safety guard: ensure lock was successfully acquired
319
+ if ( ! lock ) {
320
+ this . logger . error ( "[RunLocker] Lock was not acquired despite completing retry loop" , {
321
+ name,
322
+ resources : sortedResources ,
323
+ maxRetries,
324
+ totalWaitTime : Math . round ( totalWaitTime ) ,
325
+ lastError : lastError ?. message ,
326
+ } ) ;
327
+ throw new LockAcquisitionTimeoutError (
328
+ sortedResources ,
329
+ Math . round ( totalWaitTime ) ,
330
+ maxRetries + 1 ,
331
+ `Lock acquisition on resources [${ sortedResources . join ( ", " ) } ] failed unexpectedly`
332
+ ) ;
333
+ }
334
+
318
335
// Create an AbortController for our signal
319
336
const controller = new AbortController ( ) ;
320
337
const signal = controller . signal as redlock . RedlockAbortSignal ;
You can’t perform that action at this time.
0 commit comments