test: agent-session-bash-persistence 'cleans spill' races with other suites' pi-bash spills in the shared temp dir

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

Research direction

Open packages/coding-agent/test/suite/agent-session-bash-persistence.test.ts and read the spillFiles helper plus the assertion at line 341; the failure is that it diffs the shared tmpdir() rather than a directory owned by this test. Copy the pattern from bash-spill-final-update.test.ts, which stubs TMPDIR with a fresh mkdtemp dir before the run. Done means the file passes alone and inside the full 59-file coding-agent invocation, with the spill diff scoped to the fresh dir.

Written by the indexing model from the issue text.

Description

Failure

packages/coding-agent/test/suite/agent-session-bash-persistence.test.ts > "propagates public executeBash <stdout|stderr> async callback <string|object|Error> rejection and cleans spill" fails intermittently when the file runs in one Vitest invocation together with other suites that run bash:

AssertionError: expected [ 'pi-bash-5757882df0d3b219.log' ] to deeply equal []
 ❯ test/suite/agent-session-bash-persistence.test.ts:341:66
    expect(spillFiles().filter((file) => !before.includes(file))).toEqual([]);

Cause

The assertion diffs the shared temp directory (spillFiles = () => readdirSync(tmpdir()).filter(startsWith "pi-bash-")) before and after the run. Any other test in the same run whose bash output is truncated keeps its pi-bash-*.log spill in that same directory by design, and when it lands between the two reads this test counts it as its own leak. Which case fails changes from run to run.

Evidence (base 848ae794565fab877c4280e0aec0a5a0ec9bd2ec)

The same 59 coding-agent test files (every file importing the bash/read/write/edit tool modules), run twice in one invocation each at the base: run 1 failed "stdout async callback object rejection"; run 2 failed "stderr async callback string" and "stderr async callback object". The file alone passes (17/17, twice).

Suggested fix

Give the test its own temp directory (vi.stubEnv("TMPDIR", <fresh mkdtemp dir>) before the run, as bash-spill-final-update.test.ts does) so only this test's spills are counted.

Found while validating #6740 (identical at that PR's head and at its base; not caused by it).

Dominant language
TypeScript
Stars
517
Forks
163
Avg merge
23h 31m
Merged PRs (30d)
700

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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 code-yeongyu/senpi

All issues in code-yeongyu/senpi

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.