Skip to content

Runner: preserve complete guest output when file writes are short - #942

Closed
brandonpayton wants to merge 1 commit into
mainfrom
fix/run-example-guest-output-write-all
Closed

Runner: preserve complete guest output when file writes are short#942
brandonpayton wants to merge 1 commit into
mainfrom
fix/run-example-guest-output-write-all

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 14, 2026

Copy link
Copy Markdown
Member

Why

A short write is a successful operating-system write that stores only part of the requested buffer. Callers must retry with the remaining bytes or they silently lose data.

The generic Node example runner can capture guest stdout and stderr in a file. A successful file write is allowed to write fewer bytes than requested, but the runner treated every successful call as if it had written the complete buffer. Under a short write, the tail of guest output could be lost.

Root cause

The runner called writeSync once and ignored its returned byte count.

What changed

Add a small writeAllSync helper that:

  • advances by the number of bytes actually written;
  • retries until the complete buffer is stored; and
  • fails instead of looping forever if a write makes no progress.

The guest-output callback now uses this helper whenever file capture is enabled.

Validation

  • Focused Vitest coverage: 2 tests passed.
  • The byte-fidelity test forces repeated two-byte writes over binary data.
  • The no-progress test verifies that a zero-byte write fails instead of spinning.
  • Targeted strict TypeScript checks passed for the helper, tests, and updated runner.
  • git diff --check passed.
  • Independent review accepted the final commit with no findings.
  • The repository's normal Vitest global setup was not used for the focused local run because the disposable validation worktree did not contain the wasm64 sysroot fixture; CI remains responsible for the complete repository gate.

ABI

No ABI change. This is generic Node runner I/O behavior and does not change any kernel, host-worker, package, or Wasm interface.

@brandonpayton

Copy link
Copy Markdown
Member Author

Absorbed by rebase-merged #967. Main is now 6efb411 with the sealed tree b133bfa018f7e2bc84c4845edf2f945b2f844954, and ABI 41 activation completed successfully in run 29550069085. The absorption audit confirmed this PR\x27s behavior and tests are present in that merged tree, so this source PR is closed and its branch is deleted.

@brandonpayton
brandonpayton deleted the fix/run-example-guest-output-write-all branch July 17, 2026 02:39
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.

1 participant