Skip to content

ui-server: ask_user_form turn-limit case intermittently never sees its terminal frame #3553

Closed

Description

@schlessera

Context

packages/ui-server/tests/ws-ask-turn-timeout.test.ts "a pending question when the host's turn limit runs out > ask_user_form > expires at the original elapsed deadline, counting the wait, and says the host's limit ended it" failed once in hosted CI with waitFor timed out at packages/ui-server/tests/ws-ask-turn-timeout.test.ts:163 (await waitFor(() => terminal() !== undefined)). The case took 3640 ms. The sibling ask_user, ask_user_list and ask_user_rank cases passed in about 350 to 430 ms each in the same run.

  • Run 41780062866, job unit (2), for test(ui-server): join the journal's startup release before counting native sockets #3552 (a test-only change to http-supported-mounts.test.ts) at head 35313bdfa26b84c4509e5e96a5f4a51a20f0cf88, merge checkout 5ba62aa6897766bf1fcc801ebb619e457212da65 (base main 2fa67923d). It was the only failure among 1740 tests on that worker.
  • Not reproduced locally: 40 isolated runs of the file and 36 runs at 12-way parallel load all passed.

The case's turn limit is a real 300 ms timer (TIMEOUT = 300, ask after 200 ms). waitFor (packages/ui-server/tests/ws-ask-turn-timeout.test.ts:117-123) polls 600 times at 5 ms, a wall-clock budget of about 3 s. So either the terminal result frame for ask_user_form was never sent after the turn limit fired, or it took more than about 3 s on a loaded runner. Which of the two is not established.

Scope

Determine which. Capture the ordering of the turn-limit abort, the form drain and the terminal result frame in a failing invocation (forced delay or instrumentation). Then either fix the product ordering, or make the case wait on the observable completion condition under docs/process/test-waits.md instead of a wall-clock poll budget.

Out of scope

  • Retries, raised poll counts or longer real-time budgets as the fix.
  • Changing the 300 ms production-shaped turn limit semantics the case asserts.

Acceptance criteria

  • The cause is named with a file:line citation from a failing invocation captured on purpose.
  • The case passes 30 consecutive isolated runs and the ui-server suite.
  • A mutation receipt shows the case still fails if the turn limit's terminal frame is not sent for ask_user_form.

Verification

bun test --timeout 30000 packages/ui-server/tests/ws-ask-turn-timeout.test.ts repeated, then bun run test in packages/ui-server.

Contract impact

None expected.

Activity

  1. added this to the 0.45.0 milestone on Nov 4, 2026
  2. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p1Scheduled into the current or next milestone.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 4, 2026
  3. self-assigned this
    on Nov 4, 2026
  4. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Claiming (token c3553-d742). Branch fix/3553-ask-form-turn-limit. I'll capture the failing ordering on purpose before choosing a product or test-wait fix.

  5. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Delivered by #3557 (squash 5d461c516, on main).

    Cause. The turn limit is armed at packages/ui-server/src/ws/session-run/turn.ts:34, several awaits before backend.startTurn. On a loaded runner the 300 ms limit fired before the backend's question (asked 200 ms into startTurn). The drain (packages/ui-server/src/ws/session-run/admission.ts:57) then found nothing, and the question opened afterwards was never settled. So the terminal frame was never sent; it was not merely late. Captured on purpose by adding a 150 ms delay before startTurn on unchanged main: abort at 167 ms, question at 367 ms, the question still pending a second later, and waitFor timed out at the terminal wait. That is the hosted signature.

    Fix. Product: every interactive opener (four ask kinds, approval, location, mask) refuses a request raised after its aborted turn was drained, using the drain's reason. Test: the turn-limit case holds the host's registered limit timer on a test clock, asserts the exact boundary (299 ms no, 300 ms yes, not restarted by the question), and gains a case per ask kind for a question raised after the limit ran out.

    Receipts (failing-first, mutations including AC3's form-drain mutation, 30 of 30 isolated runs, 24 concurrent single-CPU runs) are in the PR. Hosted confirmation passed in run 41815841868 at head 92f9cb2ca on base 86dff9e41.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p1Scheduled into the current or next milestone.type: testCoverage, harness or proof work with no behaviour change.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions