ui-server: run-session's error-result test waits only 200 one-millisecond ticks for the first prompt

Open Beginner friendly
#4,066 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
bun, typescript
Domain
testing

Research direction

Read the until helper at packages/ui-server/tests/run-session.test.ts:80-86 first: it polls with 200 one-millisecond setTimeouts, which is the budget that runs out under load. Then look at the failing case at run-session.test.ts:452-458 to see what it waits for and whether the prompt exposes a promise that can be awaited instead. Replace the tick count with a wall-clock deadline or that promise, keeping a failure path for a prompt that never arrives. Done means bun run test packages/ui-server/tests/run-session.test.ts passes 20 consecutive runs under a CPU-burn loop and still fails when the first prompt is suppressed.

Written by the indexing model from the issue text.

Description

agent-ready area: ui-server priority: p3 type: test

Context

runSession > an error result fails its turn and is cleared before the next queued turn (packages/ui-server/tests/run-session.test.ts:452-458) waits for the backend's first prompt with until (run-session.test.ts:80-86). until polls 200 times with a 1 ms setTimeout, so its whole budget is roughly 200 ms of timer ticks.

Observed once locally, 2026-11-15, during a 124-file bun run test of ui-server files running alongside other worktrees' suites. It failed with error: condition was not reached at run-session.test.ts:458. The same file passes alone (16/16) on the same tree, and the change under test there (#3733) does not touch runSession. This is a timing budget under CPU load, not a product failure.

Scope

  • Give the wait a budget that does not depend on how quickly 1 ms timers fire under load, for example a deadline in wall time or awaiting the prompt's own promise.

Out of scope

  • runSession behaviour.

Acceptance criteria

  • The test passes under a CPU-burn loop across 20 consecutive runs, and still fails if the first prompt never arrives.

Verification

bun run test packages/ui-server/tests/run-session.test.ts, under load.

Contract impact

None.

2026-11-16 triage at main 3b104890f8: Verified until (packages/ui-server/tests/run-session.test.ts:80-86) and the prompt wait in the named case. This is a scoped test synchronization repair: wait on the observable prompt or a finite elapsed deadline, record the chosen bound, and retain a prompt-never-arrives negative control within the test’s existing outer timeout. Preserve all run-session outcome/queue assertions and meaningful cleanup. No production or UX choice is open. Preserve p3, add agent-ready, and keep standalone because the matching keyless epic #736 already has 100 direct children.

Dominant language
TypeScript
Stars
4
Forks
0
Avg merge
6h 5m
Merged PRs (30d)
730

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from schlessera/brain-kit

All issues in schlessera/brain-kit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.