fix: add size guard to FileModel::reload_file_paths() to prevent OOM on large file reloads (APP-4519)#12185
Draft
warp-dev-github-integration[bot] wants to merge 1 commit into
Conversation
…on large file reloads (APP-4519) FileModel::open() already has a 50 MB size guard (added by PR #12125), but reload_file_paths() — called when file watcher detects changes to tracked files — still uses async_fs::read_to_string without any size check. If a tracked file grows very large (e.g. log files, database dumps), the reload path reads the entire file into memory. Sentry issue 7259255054 (event 4e0cc766, Linux stable) shows 56 GB sampled heap from this path. This change applies the same read_file_with_size_limit() guard to the reload path, logging a warning and silently skipping files that exceed MAX_EDITOR_FILE_SIZE_BYTES (50 MB). Co-Authored-By: Oz <oz-agent@warp.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds the same
MAX_EDITOR_FILE_SIZE_BYTES(50 MB) size guard toFileModel::reload_file_paths()that PR #12125 added toFileModel::open().Problem:
reload_file_paths()— called when the file watcher detects changes to tracked files — usesasync_fs::read_to_stringwithout any file size check. If a tracked file grows very large (e.g., log files, database dumps, build artifacts), the reload path reads the entire file into memory, causing massive allocations.Evidence: Sentry issue 7259255054 (event
4e0cc766, Linux stable) shows 56.12 GB sampled heap, with 99.79% fromasync_fs::read_to_string→std::fs::read_to_string::innervia the blocking executor thread pool.Fix: Replace the bare
async_fs::read_to_stringinreload_file_paths()with the existingread_file_with_size_limit()helper. Files exceeding 50 MB are silently skipped with a warning log instead of being read into memory.Changes:
crates/warp_files/src/lib.rs— Useread_file_with_size_limit()inreload_file_paths()instead of unboundedasync_fs::read_to_stringThis is a companion to PR #12125 (which guards
open()) and is based on that branch.Linked Issue
Sentry: https://sentry.io/organizations/warpdotdev/issues/7259255054/
ready-to-specorready-to-implement.Testing
./script/runThe fix uses the same
read_file_with_size_limit()helper that PR #12125 introduces and validates. Files larger than 50 MB in tracked editor paths will be silently skipped during file-watcher reloads instead of being loaded into memory.cargo check -p warp_filesandcargo clippy -p warp_files -- -D warningspass cleanly.Agent Mode
Conversation: https://staging.warp.dev/conversation/6a5dea71-bdbb-4a0b-b2f1-67ded4640aef
Run: https://oz.staging.warp.dev/runs/019e9164-45fe-70f6-a07b-440e8bc70444
This PR was generated with Oz.
Linear Issue
APP-4519