fix(github): drop per-file patch in getPullRequestFiles to bound memory#111
fix(github): drop per-file patch in getPullRequestFiles to bound memory#111loks0n wants to merge 1 commit into
Conversation
getPullRequestFiles() paginated a pull request's files and accumulated the full GitHub file objects -- including each file's `patch` (the complete unified diff) -- into one array before returning. `patch` is the only unbounded field (KBs-MBs per file) and grows with PR size, so a large PR (thousands of files, e.g. generated code / lockfiles / vendored deps) materialised every diff in memory at once -- hundreds of MB in a single request. No caller uses `patch`; both consumers only read `filename` / `previous_filename`. Strip `patch` per page while paginating. The return shape is preserved (array of file objects keyed by `filename`, etc.), so memory is bounded to lightweight per-file metadata. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR removes the
Confidence Score: 5/5Safe to merge — a minimal, well-scoped change that drops an unused field during pagination without altering the return contract. The change touches a single loop in one method. The No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(github): drop per-file patch in getP..." | Re-trigger Greptile |
Problem
GitHub::getPullRequestFiles()paginates a pull request's files and accumulates the full GitHub file objects — including each file'spatch(the complete unified diff) — into one array before returning:patchis the only unbounded field (KBs–MBs per file) and grows with PR size. A large PR (thousands of files — generated code, lockfiles, vendored deps) materialises every diff in memory at once — hundreds of MB in a single request. In a long-running Swoole worker this drives the process toward its memory limit and OOM.No caller uses
patch: both consumers (appwrite/server-ce's GitHub events handler and external-PR authorize handler) only readfilename/previous_filenameviaarray_column().Fix
Strip
patchper page while paginating:The return shape is preserved (array of file objects keyed by
filename,status, etc.), so existing behaviour and thearray_column($result, 'filename')assertions in the GitLab/Gitea adapter tests are unaffected. Memory is now bounded to lightweight per-file metadata.Test plan
php -lclean.patch;filename/previous_filenameand all other metadata fields remain present.🤖 Generated with Claude Code