Skip to content

Notify about a background command only once its output file is complete - #445

Merged
ilovepixelart merged 3 commits into
ilovepixelart:mainfrom
sproott:fix-bash-cap-test
Nov 15, 2026
Merged

ilovepixelart merged 3 commits into
ilovepixelart:mainfrom
sproott:fix-bash-cap-test

Conversation

@sproott

@sproott sproott commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

A background command's output reaches its file through fs.createWriteStream, and the completion notice was sent as soon as the command ended. A model reading the file right after the notice could find it empty or without its tail.

On Windows CI this failed two tests in tests/background-bash.test.ts:

Test Failure
starts a run_in_background command and notifies when it completes expected '' to contain 'finished'
stops a background command whose output passes the cap, and says so expected 1720 to be greater than 4096

The command is now settled, and its notice sent, once the output stream has closed.

A new test delays every write to the output file by 150 ms and reads the file when the notice arrives. It fails without the change with expected '' to contain 'finished'.

  • npm run check passes (Biome, strict tsc, Vitest)
  • Tests cover the change

The command's output reaches its log file through an asynchronous write
stream, and the completion notice went out as soon as the command ended.
A model reading the file right after the notice could get it without its
tail; on CI this failed the cap test (ilovepixelart#441, ilovepixelart#443) and the one-copy test.
Settling now waits for the stream to close.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With every write to the output file delayed by 150 ms, the notice for
`echo finished` arrived while the file was still empty. The test fails
with "expected '' to contain 'finished'" when the notice is sent before
the stream has closed.
@ilovepixelart ilovepixelart changed the title Wait for the background log to reach the cap before checking its size Notify about a background command only once its output file is complete Nov 15, 2026
@ilovepixelart
ilovepixelart merged commit cb2e23f into ilovepixelart:main Nov 15, 2026
12 checks passed
@sproott
sproott deleted the fix-bash-cap-test branch November 16, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants