mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 19:38:58 +00:00
Fixes #2570 Previously, `readFileSync` with string encodings (utf8, ascii, etc.) only checked against `synthetic_allocation_limit` (~4GB), but WebKit's `WTF::String::MaxLength` is only ~2GB (`std::numeric_limits<int32_t>::max()`). This mismatch caused large files (>2GB) to be silently truncated when converted to strings, resulting in confusing "JSON Parse error: Unexpected EOF" errors instead of a clear memory error. The fix: - Changes `string_allocation_limit` default from `maxInt(u32)` to `maxInt(i32)` to match WebKit's String::MaxLength - Updates `shouldThrowOutOfMemoryEarlyForJavaScript` to use the appropriate limit based on encoding type (buffer encoding uses higher typed array limit, string encodings use the WebKit string limit) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>