Skip to content

fs: back createWriteStream(path) with a FileSink that adopts the fd - #35993

Open
robobun wants to merge 32 commits into
mainfrom
farm/d9a91b9d/fs-writestream-filesink
Open

fs: back createWriteStream(path) with a FileSink that adopts the fd#35993
robobun wants to merge 32 commits into
mainfrom
farm/d9a91b9d/fs-writestream-filesink

on_auto_flush: keep flushing when done with pending data; move close_…

b9e3848
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 27, 2026 in 46m 10s

Code review found 2 important issues

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

Details

Severity Count
🔴 Important 2
🟡 Nit 1
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/io/PipeWriter.rs:2649-2653 Windows borrowed Pipe/Tty: end() early-return still leaks keep-alive ref
🟡 Nit packages/bun-types/s3.d.ts:17-25 ArrayBufferSink type declaration missing writev()

Annotations

Check failure on line 2653 in src/io/PipeWriter.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Windows borrowed Pipe/Tty: end() early-return still leaks keep-alive ref

The 3731912 revert restored the early `return` for a borrowed Pipe/Tty source (avoiding the `on_close_source` UAF), but that reintroduces the keep-alive leak: `on_close` never fires, so `clear_keep_alive_ref` never releases the `must_be_kept_alive_until_eof` self-ref taken on the first `Pending` write, and the native FileSink + `Box<uv::Pipe>` live for the process lifetime. The comment "uv_close on Drop" is unreachable — Drop never runs because that self-ref pins refcount ≥ 1. Fix: fire `Parent:

Check warning on line 25 in packages/bun-types/s3.d.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

ArrayBufferSink type declaration missing writev()

`writev()` is added to all six sink prototypes (including `ArrayBufferSink` — exercised at filesink.test.ts:215-220), but only `interface FileSink` gets a type declaration. `class ArrayBufferSink` at packages/bun-types/bun.d.ts:1925-1952 is a standalone declaration (doesn't extend `FileSink`), so `new Bun.ArrayBufferSink().writev([...])` fails typecheck even though it now works at runtime. Add `writev(chunks: ArrayBufferView[]): number;` there too. (`NetworkSink extends FileSink` so it inherits