Skip to content

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
fix/large-file-oom-code-editor-APP-XXXXfrom
fix/reload-file-paths-size-guard-APP-4519
Draft

fix: add size guard to FileModel::reload_file_paths() to prevent OOM on large file reloads (APP-4519)#12185
warp-dev-github-integration[bot] wants to merge 1 commit into
fix/large-file-oom-code-editor-APP-XXXXfrom
fix/reload-file-paths-size-guard-APP-4519

Conversation

@warp-dev-github-integration
Copy link
Copy Markdown

Description

Adds the same MAX_EDITOR_FILE_SIZE_BYTES (50 MB) size guard to FileModel::reload_file_paths() that PR #12125 added to FileModel::open().

Problem: reload_file_paths() — called when the file watcher detects changes to tracked files — uses async_fs::read_to_string without 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% from async_fs::read_to_stringstd::fs::read_to_string::inner via the blocking executor thread pool.

Fix: Replace the bare async_fs::read_to_string in reload_file_paths() with the existing read_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 — Use read_file_with_size_limit() in reload_file_paths() instead of unbounded async_fs::read_to_string

This 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/

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

Testing

  • I have manually tested my changes locally with ./script/run

The 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_files and cargo clippy -p warp_files -- -D warnings pass cleanly.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI 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

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant