Bun.write: keep stdio writes in call order when stdout/stderr is a regular file - #35949
Closed
robobun wants to merge 1 commit into
Closed
Bun.write: keep stdio writes in call order when stdout/stderr is a regular file#35949robobun wants to merge 1 commit into
robobun wants to merge 1 commit into
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
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.
Loading