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

Open Beginner friendly
#4,247 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
87/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
testing

Research direction

Start with the calls() helper in packages/ui-server/tests/web-tools-broker.test.ts and the fixture writer in packages/ui-server/tests/fixtures/web-executor.ts. Search packages/ui-server/tests/ for other calls.jsonl readers, then check the helper with an empty file and one ending in an incomplete line. Done when incomplete lines are ignored by all readers and the acceptance checks pass.

Written by the indexing model from the issue text.

Description

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

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.
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.