Skip to content

Bun.file: make exists()/size/lastModified reflect the current filesystem state - #33659

Open
robobun wants to merge 20 commits into
mainfrom
farm/1db7f535/bunfile-stat-cache
Open

Bun.file: make exists()/size/lastModified reflect the current filesystem state#33659
robobun wants to merge 20 commits into
mainfrom
farm/1db7f535/bunfile-stat-cache

extract stat_file_size helper shared by get_size, get_size_for_bindin…

72053b5
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 28, 2026 in 28m 40s

Code review found 2 potential issues

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

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/runtime/webcore/Blob.rs:2275-2282 view_size() skips clamp for explicit file slices, so nested .slice(-N) diverges from .size

Annotations

Check warning on line 2282 in src/runtime/webcore/Blob.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

view_size() skips clamp for explicit file slices, so nested .slice(-N) diverges from .size

`view_size()` still skips `stat_file_size` for explicit file slices (`!self.size_is_explicit.get()` at line 2277), so a nested negative-index slice resolves against the raw bound rather than the clamped `.size`: for `s = Bun.file(threeByteFile).slice(0, 100)`, `s.size === 3` but `s.slice(-1)` uses 100 → offset 99 → `""` instead of `"c"`. This is the same `.size`-vs-size-consumer divergence already fixed for `get_size_for_bindings` in aaa9c8a9/72053b5e, at the remaining `view_size()` call site (`