From 2e779a7c60b580f1e05c2e7c43cdda7d5b205f08 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Sat, 17 Oct 2026 13:33:06 +0200 Subject: [PATCH] fix(leasing): the #armTimeout comment states what its markNew callers do (#666) --- src/leasing/wait-queue.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/leasing/wait-queue.ts b/src/leasing/wait-queue.ts index f8d52ba5a..042d531dc 100644 --- a/src/leasing/wait-queue.ts +++ b/src/leasing/wait-queue.ts @@ -329,7 +329,7 @@ export class WaitQueue { } /** - * Arms (or re-arms, after a cycle back through `queued`) this waiter's timeout. `deadlineAt` is + * why: Arms (or re-arms, after a cycle back through `queued`) this waiter's timeout. `deadlineAt` is * computed once, the first time a waiter with a `timeoutMs` is ever armed, and never moved * afterward -- every later call here (a re-enqueue `enqueue` already let through because the * deadline had not yet passed) times the remaining budget against that same fixed deadline @@ -362,11 +362,13 @@ export class WaitQueue { * would have fired at the identical moment anyway), but real, not merely theoretical -- * `FakeClock` (every test here) never fires early, so no test under it can ever land in this * window, which is why the difference is a doc claim to get right rather than a behavior to - * cover with one. Separately: `markNew` (below) is a public path back to `queued` that arms no - * timer at all -- a waiter it returns to `queued` sits with no deadline until some *other* - * `enqueue` call re-arms it, which is a real gap in `timeoutMs` enforcement for whichever - * caller uses that path (`LeaseAcquisitionCoordinator`'s own eviction and provision-retry - * callers, not this module's problem to close on its own). + * cover with one. + * + * `markNew` arms nothing, and that is safe only because its callers hand the waiter straight + * back to a decision: every branch of that decision that keeps the waiter alive passes + * `#expireIfPastDeadline` (through `markProcessing`) or `enqueue`'s own upfront check first. A + * caller that returned without re-deciding would leave a waiter `queued` with a fixed deadline + * and no timer, and would have to arm here. */ #armTimeout(waiter: MutableWaiter): void { if (waiter.timer !== undefined || waiter.options.timeoutMs === undefined) return;