fix: add 50 MB file size limit in code editor to prevent OOM from large files#12125
Draft
warp-dev-github-integration[bot] wants to merge 1 commit into
Draft
fix: add 50 MB file size limit in code editor to prevent OOM from large files#12125warp-dev-github-integration[bot] wants to merge 1 commit into
warp-dev-github-integration[bot] wants to merge 1 commit into
Conversation
…ge files When a very large file is opened in the code editor, the buffer materializes the entire content as Vec<StyledBufferBlock>, which is then cloned in CodeEditorModel::handle_content_model_event, and tree-sitter also parses the complete content. Together these operations can consume many gigabytes of RAM for large files — a real-world Sentry event (issue 7259255054) showed 7.6 GB of live heap from a single file load (3.15 GB in SumTree, 1.52 GB from delta clone, 2.87 GB tree-sitter). Add FileLoadError::FileTooLarge and a MAX_EDITOR_FILE_SIZE_BYTES (50 MB) limit in FileModel::open via a new read_file_with_size_limit helper. Files exceeding this threshold emit FailedToLoad, which the code editor handles by showing the standard load-failure toast. The existing read_content_for_file (used by discard_unsaved_changes and tests) is left unchanged since those paths are intentional and bounded by user action rather than background auto-load. Fixes Sentry issue: https://sentry.io/organizations/warpdotdev/issues/7259255054/ Co-Authored-By: Oz <oz-agent@warp.dev>
This was referenced Jun 3, 2026
Closed
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 a 50 MB file size limit in
FileModel::opento prevent extreme memory usage when the code editor opens a very large file.Root cause: When a large file is loaded in the code editor:
Buffer::replace_allmaterializes the entire file asVec<StyledBufferBlock>— proportional to file size (3.15 GB in the Sentry event)CodeEditorModel::handle_content_model_eventclones theEditDeltacontaining all styled blocks (1.52 GB)SyntaxTreeState::update_internal_state_with_deltaparses the entire content with tree-sitter (2.87 GB)Together these consumed 7.6 GB of heap for a single file open (Sentry issue 7259255054,
warp-client-beta-stable, MacBookPro18,2 w/ M1 Max,mac_stable_release).Fix: A new
read_file_with_size_limithelper inFileModel::openchecksasync_fs::metadatabefore reading. Files larger thanMAX_EDITOR_FILE_SIZE_BYTES(50 MB) emitFailedToLoadinstead of being read into memory. The code editor shows the standard load-failure toast.Changes:
crates/warp_util/src/file.rs— AddFileLoadError::FileTooLarge { size_bytes, limit_bytes }variantcrates/warp_files/src/lib.rs— AddMAX_EDITOR_FILE_SIZE_BYTESconstant (50 MB),read_file_with_size_limitasync helper, wire it intoFileModel::openapp/src/ai/blocklist/action_model/execute.rs— AddFileTooLargearm to exhaustive matchLinked Issue
Sentry: https://sentry.io/organizations/warpdotdev/issues/7259255054/
ready-to-specorready-to-implement.Testing
./script/runThe affected code path is tested by: attempting to open a file larger than 50 MB in the code editor — it should show the "failed to load" toast instead of consuming gigabytes of RAM.
Agent Mode
Conversation: https://staging.warp.dev/conversation/1f7b5e5a-c53a-4576-9bae-c8ec63d3c68f
Run: https://oz.staging.warp.dev/runs/019e8bd0-5b45-7040-aaab-09e52b40bf93
This PR was generated with Oz.
Linear Issue
APP-4519