fix(agent-core): bound Git diff output while reading#2171
Open
morluto wants to merge 2 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: 676a072 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Related Issue
Resolve #2169
Problem
The Git services applied their 1 MiB file-diff limit only after collecting complete subprocess stdout. Large diffs could therefore create memory spikes proportional to the full diff even though callers received at most 1 MiB.
The old limit also measured JavaScript string length rather than UTF-8 bytes, allowing multibyte responses to exceed the intended byte ceiling.
A representative 24 MiB modified file increased peak RSS to 331 MiB before this change and 231 MiB afterward. The measurement includes Git, fixture data, decoding, and V8 overhead; the code-level guarantee is that the retained diff response is now bounded rather than scaling with complete stdout.
What changed
Other Git commands, stderr collection, timeout behavior, and exit-code handling are unchanged.
Regression tests exercise both services through their existing public boundaries with a 1.2 MiB multibyte diff. They fail on the previous implementation because it returns
truncated: falseand exceeds the byte limit.Validation:
git diff --checkChecklist
gen-changesetsskill, and included a patch changeset.