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 {
213213 let totalWaitTime = 0 ;
214214
215215 // Retry the lock acquisition with exponential backoff
216- let lock : redlock . Lock ;
216+ let lock : redlock . Lock | undefined ;
217217 let lastError : Error | undefined ;
218218
219219 for ( let attempt = 0 ; attempt <= maxRetries ; attempt ++ ) {
@@ -315,6 +315,23 @@ export class RunLocker {
315315 throw lastError ;
316316 }
317317
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+
318335 // Create an AbortController for our signal
319336 const controller = new AbortController ( ) ;
320337 const signal = controller . signal as redlock . RedlockAbortSignal ;
You can’t perform that action at this time.
0 commit comments