File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -293,12 +293,13 @@ async function tryAcquireDistributedLease(
293293 return 1
294294 `
295295
296- const deadline = new Promise < never > ( ( _ , reject ) =>
297- setTimeout (
296+ let deadlineTimer : NodeJS . Timeout | undefined
297+ const deadline = new Promise < never > ( ( _ , reject ) => {
298+ deadlineTimer = setTimeout (
298299 ( ) => reject ( new Error ( `Redis lease timed out after ${ LEASE_REDIS_DEADLINE_MS } ms` ) ) ,
299300 LEASE_REDIS_DEADLINE_MS
300301 )
301- )
302+ } )
302303
303304 try {
304305 const result = await Promise . race ( [
@@ -318,6 +319,8 @@ async function tryAcquireDistributedLease(
318319 } catch ( error ) {
319320 logger . error ( 'Failed to acquire distributed owner lease' , { ownerKey, error } )
320321 return 'unavailable'
322+ } finally {
323+ clearTimeout ( deadlineTimer )
321324 }
322325}
323326
You can’t perform that action at this time.
0 commit comments