Skip to content

Bun.write: keep stdio writes in call order when stdout/stderr is a regular file - #35949

Closed
robobun wants to merge 1 commit into
mainfrom
farm/358e96be/bun-write-stdout-order
Closed

Bun.write: keep stdio writes in call order when stdout/stderr is a regular file#35949
robobun wants to merge 1 commit into
mainfrom
farm/358e96be/bun-write-stdout-order

Bun.write: keep stdio writes on the sync fast path when the fd is a r…

5a03f8c
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 26, 2026 in 17m 5s

Code review found 1 important issue

Found 1 candidates, confirmed 1. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/runtime/webcore/Blob.rs:5054-5056 Empty Bun.write to file-redirected stdout/stderr now ftruncates the output file

Annotations

Check failure on line 5056 in src/runtime/webcore/Blob.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Empty Bun.write to file-redirected stdout/stderr now ftruncates the output file

Routing regular-file fd blobs into the sync fast path exposes them to the `truncate = NEEDS_OPEN || input.is_empty()` clause at Blob.rs:5423/:5507 — with `NEEDS_OPEN=false` and an empty payload, this now issues `ftruncate(fd, 0)` on a regular file (where it *succeeds*, unlike the pipe/tty case that harmlessly EINVALs). So `Bun.write(Bun.stdout, "")` under `> out.txt` now wipes everything already written, whereas before this PR it went through the async `WriteFileTask` path which never truncates.