Skip to content

Bun.write: poll instead of spin when a nonblocking stdout pipe returns EAGAIN - #35953

Open
robobun wants to merge 6 commits into
mainfrom
farm/4588fdfb/bun-write-stdout-eagain-spin
Open

Bun.write: poll instead of spin when a nonblocking stdout pipe returns EAGAIN#35953
robobun wants to merge 6 commits into
mainfrom
farm/4588fdfb/bun-write-stdout-eagain-spin

[autofix.ci] apply automated fixes

82c7c82
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 26, 2026 in 23m 34s

Code review found 1 potential issue

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

Details

Severity Count
🔴 Important 0
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/webcore/blob/write_file.rs:467-477 Dup can land on fd 0/1/2 and be skipped by do_close's stdio_tag() guard

Annotations

Check warning on line 477 in src/runtime/webcore/blob/write_file.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Dup can land on fd 0/1/2 and be skipped by do_close's stdio_tag() guard

Minor edge case: `bun_sys::dup(fd)` lowers to `fcntl(F_DUPFD_CLOEXEC, 0)` (src/sys/lib.rs:2578), so if a stdio slot happens to be closed the dup can land on 0/1/2 — the new `is_allowed_to_close()` Fd arm returns true, but `FileCloser::do_close` (Blob.rs:7229) then vetoes the close via `opened_fd().stdio_tag().is_none()`, so that one dup is kept open. Impact is bounded (≤ one fd per free stdio slot, since the kept dup fills the slot and later dups return ≥3) and the trigger requires a stdio fd to