Skip to content

fs: treat negative/non-number position in readv/writev as current offset - #32292

Closed
robobun wants to merge 4 commits into
mainfrom
farm/dc6d4893/fs-readv-writev-negative-position
Closed

robobun wants to merge 4 commits into
mainfrom
farm/dc6d4893/fs-readv-writev-negative-position

fs: treat negative/non-number position in readv/writev as current offset

67acef5
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 16, 2026 in 13m 49s

Code review found 2 potential issues

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

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit test/js/node/fs/fs.test.ts:5349-5362 Buffer-pin test drops disk verification for the first (pwritev) write
🟡 Nit src/runtime/node/node_fs.rs:2847-2853 NaN/Infinity position still diverges from Node

Annotations

Check warning on line 5362 in test/js/node/fs/fs.test.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Buffer-pin test drops disk verification for the first (pwritev) write

The second (non-positional) writev now lands at offset 0 — pwritev doesn't advance the fd offset — so its 8 `D` bytes overwrite the first write's 8 `C` bytes before `readFileSync` runs, and the first (pwritev-path) write's disk content is no longer verified. Add `expect(readFileSync(file, "latin1")).toBe("CCCCCCCC")` right after `expect(await promise).toBe(8)` so both writes' bytes are checked and the original safety-net assertion is preserved.

Check warning on line 2853 in src/runtime/node/node_fs.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

NaN/Infinity position still diverges from Node

Nit: `NaN` and `+Infinity` still diverge from Node here — `is_number()` is true for both, and `to_int64()` maps NaN→0 and +Infinity→`i64::MAX`, so `writevSync(fd, bufs, NaN)` does `pwritev` at offset 0 while Node (via `IsSafeJsInt` → -1) writes at the current offset. Pre-existing behavior, not a regression, but since this branch is being rewritten specifically to match Node/libuv semantics it's worth gating on a finite/safe-integer check and adding `NaN`/`Infinity` to the `describe.each` matrix.