Bun.file: make exists()/size/lastModified reflect the current filesystem state - #33659
Closed
robobun wants to merge 20 commits into
Closed
Bun.file: make exists()/size/lastModified reflect the current filesystem state#33659robobun wants to merge 20 commits into
robobun wants to merge 20 commits into
Claude / Claude Code Review
completed
Jul 28, 2026 in 26m 26s
Code review found 2 important issues
Found 2 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 2 |
| 🟡 Nit | 0 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🔴 Important | src/runtime/webcore/Blob.rs:2001-2008 |
get_slice on an empty regular file drops the File store |
| 🔴 Important | src/runtime/webcore/Blob.rs:765 |
serialize() still poisons self.size via resolve_size() |
Annotations
Check failure on line 2008 in src/runtime/webcore/Blob.rs
claude / Claude Code Review
get_slice on an empty regular file drops the File store
`view_size()` returns `0` for an *existing empty regular file* (`ISREG=true, st_size=0` → `max_size=0, seekable=Some(true)`), so `get_slice` hits the `this_size == 0` early exit and returns a store-less `init_empty` before any argument processing. This regresses the fresh-blob path (pre-PR the guard was `self.size.get() == 0` with `self.size == MAX_SIZE`, so the early exit was skipped): the slice loses its File backing — populate-then-`.text()` now reads `""` (the same read-poisoning class this
Check failure on line 765 in src/runtime/webcore/Blob.rs
claude / Claude Code Review
serialize() still poisons self.size via resolve_size()
`self.resolve_size()` here is the remaining sibling of the `self.size.set(...)` writes 7d808eaf removed from `get_size`: it caches a stat-derived size on the *original* blob, so `structuredClone(Bun.file(missing))` sets `self.size = 0` and a later `.text()` returns `""` — the exact #4930 shape with `structuredClone` in place of `exists()`. The call is not load-bearing (`store.serialize()` reads only `pathlike`, and the size-on-wire was already written at line 760), so it can simply be deleted to
Loading