next.js
6f763ecf - Turbopack: add anyhow::Context to turbo-persistence mmap, file open, and decompress operations (#90769)

Commit
21 hours ago
Turbopack: add anyhow::Context to turbo-persistence mmap, file open, and decompress operations (#90769) ### What? Adds `anyhow::Context` (`.context()` / `.with_context()`) to error-prone operations in the `turbo-persistence` crate: file opens, memory mapping (`mmap`), and LZ4 decompression. ### Why? `get` / `batch_get` sometimes fail with a bare "Cannot allocate memory" error, but the anyhow error chain has no context about *which* file, block, or operation caused it. This makes debugging difficult since the raw OS error propagates through bare `?` operators without any identifying information. ### How? Split double-`?` expressions (e.g. `Mmap::map(&File::open(&path)?)?`) into separate statements so each operation gets its own context. Added `.with_context()` to: - **`compression.rs`** — `decompress()` call in `decompress_into_arc()`, reporting compressed and uncompressed sizes - **`db.rs`** — `File::open`, `Mmap::map`, and `read_u32` in `read_blob()`, reporting the blob file path and size - **`static_sorted_file.rs`** — `File::open` and `Mmap::map` in `open_internal()`, `get_raw_block_slice` and `decompress_into_arc` in `read_block()`, and block offset reads in `get_raw_block_slice()`, reporting SST filename and block index - **`meta_file.rs`** — `options.map()` in `open_internal()`, reporting the meta file path An ENOMEM error will now produce a chain like: ``` Unable to open static sorted file 00000042.sst Caused by: Failed to mmap SST file /path/to/00000042.sst (1234567 bytes) Caused by: Cannot allocate memory (os error 12) ```
Author
Parents
Loading