Skip to content

test(ui-server): the web broker's calls() helper reads calls.jsonl mid-write and throws #4247

Closed

Description

@schlessera

What happens

packages/ui-server/tests/web-tools-broker.test.ts "no result returns after the turn stops being current, and a late answer to cancel is discarded" failed in CI with:

SyntaxError: JSON Parse error: Unexpected EOF
  at until (web-tools-broker.test.ts:43:11)
  at web-tools-broker.test.ts:179:9

This was hosted candidate run 44198693229, job unit (3), for PR #4240. That PR touches only ui-react markdown rendering.

Cause

The test helper calls (calls, packages/ui-server/tests/web-tools-broker.test.ts:36-37) reads calls.jsonl whenever the file exists, and parses each line of the trimmed text.

The executor fixture appends from another process with appendFileSync (packages/ui-server/tests/fixtures/web-executor.ts:58). That opens the file with create and append, then writes. So the poll inside until(() => calls().length === 1) can read the file after it is created and before the line is written: "".trim().split("\n") is [""], and JSON.parse("") throws. A partly written line throws the same way. until does not catch, so the test fails instead of polling again.

Acceptance criteria

  • calls() ignores an empty or unterminated last line, so a read in the middle of a write gives the calls already complete. For example, parse only lines ended by \n.
  • A test or a mutation shows the helper returns [] for an empty file and drops an unterminated last line.
  • Check the other calls.jsonl readers in packages/ui-server/tests/ for the same race, and fix them the same way.

Activity

  1. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p3Someday. Needs a driving use case before it starts.
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 17, 2026
  2. self-assigned this
    on Nov 18, 2026
  3. schlessera commented on Nov 18, 2026

    @schlessera
    OwnerAuthor

    Claimed for implementation. Claim token: claim-72e1b47f. Branch: test/4247-4249-4252-test-races.

    Worked together with #4247, #4249 and #4252 in one test-only PR. Collisions: closure-level only with long-lived drafts, no path collision.

  4. added this to the 0.45.0 milestone on Nov 18, 2026
  5. schlessera commented on Nov 18, 2026

    @schlessera
    OwnerAuthor

    Delivered in #4254 (squash bd751d4 on main). completeJsonLines (packages/ui-server/tests/helpers/json-lines.ts) parses only lines ended by a newline, so it returns [] for an empty file and drops an unterminated last line. Every polled JSON-lines reader in packages/ui-server/tests/ now uses it: web-tools-broker, web-pi-worker, host-version-requirements, hygiene-review, http-object-bodies, http-validation, http-supported-mounts and capture-outcome. Failing first: with the old trim().split() logic, json-lines.test.ts fails with JSON Parse error: Unexpected EOF at the empty-file case. The candidate proof passed in run 44279379494.

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: p3Someday. Needs a driving use case before it starts.type: testCoverage, harness or proof work with no behaviour change.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions