fix: prevent ENOBUFS crash and oversized input on large diffs (#11)#61
fix: prevent ENOBUFS crash and oversized input on large diffs (#11)#61Psypeal wants to merge 1 commit intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b030dcd820
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| content: enforceContentLimit(content) | ||
| }; | ||
| } | ||
| const untrackedBody = collectUntrackedBodies(cwd, state.untracked, MAX_REVIEW_CONTENT_CHARS); |
There was a problem hiding this comment.
Preserve patch output when only untracked content is oversized
In collectWorkingTreeContext, untracked files are collected with the full MAX_REVIEW_CONTENT_CHARS budget before staged/unstaged sections are accounted for, so a repo with many untracked files and a small patch can still exceed the global limit and trigger the later stat-only fallback. That causes the actual patch hunks to be replaced by --stat output even when the diff itself is not large, which drops review-critical detail and mislabels the reason as “full diff too large.”
Useful? React with 👍 / 👎.
Add maxBuffer (50MB) to spawnSync, estimate diff size via --numstat before reading full patches, gracefully fall back to --stat summaries when diffs exceed the review content budget or fail to read, and hard-cap all review output to stay within the Codex API input limit.