Skip to content

WaitQueue#markNew returns a waiter to queued with no timeout armed #657

Closed as not planned

Description

@V3RON

Found while triaging #647.

WaitQueue#markNew (src/leasing/wait-queue.ts:273) sets a waiter back to queued without calling #armTimeout (src/leasing/wait-queue.ts:371), which is only reached from enqueue (wait-queue.ts:246). A waiter whose timer already fired mid-attempt (the processing non-reject branch) and is then returned by markNew sits queued with timer === undefined and deadlineAt already past: no timer can reject it, and it is only settled if some later enqueue/markProcessing happens to run its deadline check. The lease coordinator's markNew callers are the eviction continue path and the provision-retry first failure, so a waiter on either can outlive its timeoutMs indefinitely.

The gap is named in the comment at wait-queue.ts:365-369 but has no issue. Its edge is a waiter past deadlineAt that nothing ever re-enqueues.

Written by an agent.

Activity

  1. added
    bug:new
    and removed
    bug:new
    on Oct 17, 2026
  2. self-assigned this
    on Oct 17, 2026
  3. V3RON commented on Oct 17, 2026

    @V3RON
    ContributorAuthor

    Could not reproduce on main (44290384, which includes #647's fix). No waiter is left queued with a past deadline and no armed timer, because both markNew callers decide the waiter again before the decision section ends, and every branch of that decision checks the deadline.

    What I tried. Unit tests over LeaseAcquisitionCoordinator's own surface (FakeClock, its real WaitQueue, Registry on MemoryFilesystem), staging the processing non-reject branch by gating the eviction's driver call so the armed deadline expires mid-attempt. Both markNew call sites were reached, not modelled:

    • #provision's first-failure retry (lease-acquisition-coordinator.ts:849) — returns true, and await this.#drive(waiter) runs on the next line.
    • #continueAfterEviction (:1008) — markNew then return this.#decide(waiter) inside the same decisions.run.

    In both, the caller got its error and the record closed:

    callerError: 'QueueTimeoutError', outcome: 'rejected', queueDepth: 0,
    states: ['iPhone SE:shutdown', 'iPhone 16:provisioning', 'iPhone 16:ready'],
    stored: ['evicted:failed']
    

    Why the edge is unreachable. markNew does arm nothing, but the waiter never sits there: #decide reaches markProcessing (:886/:900) or #defer → #enqueue, and markProcessing runs the same #expireIfPastDeadline as enqueue (wait-queue.ts:254 vs :236). The window between markNew and that check is inside one synchronous section, so no caller, event or record can observe it. Nothing to reproduce means no failing test, so there is no bug/657-repro branch.

    What would change this. A markNew caller that does not decide the waiter again in the same section — a third caller, or #decide returning before markProcessing/#defer for a waiter that has a spec (today it reaches both, or rejects). Then a queued waiter would keep its past deadline with no timer, as filed.

    The comment this issue cites is wrong on its own; filed as #666. Two other things fell out of these runs: #665 (the operation branch at :900 discards markProcessing's false and provisions a device for a waiter already rejected with QueueTimeoutError — seen: ['provision@1160 waiter=rejected']), and the accepted-but-undocumented case where a first attempt plans device work immediately, so no timer is armed and a grant can land past timeoutMs (--timeout is documented as queue wait, so not filed).

    Written by an agent.

  4. added
    bug:needs-info
    and removed on Oct 17, 2026
  5. removed their assignment
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:needs-info

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions