fix: prevent ENOBUFS in push_repo_memory on large repos#23069
Conversation
Replace git sparse-checkout disable + git rm -rf . (which pipes one line per file and overflows the buffer on 10K+ file repos) with: - git read-tree --empty (clears index in O(1), zero output) - Node.js fs.rmSync loop (no pipe, no buffer issues) Also remove sparse-checkout disable entirely: it forces a full working-tree expansion and is not needed for orphan branch creation or memory branch checkout. Fixes: push_repo_memory fails with ENOBUFS on large repos after disabling sparse checkout (Azure/azure-sdk-for-js ~10K files) Also fix pre-existing test failure: import afterEach from vitest Agent-Logs-Url: https://github.com/github/gh-aw/sessions/04d764a4-b984-43c6-a10f-b599f2dc3c16 Co-authored-by: pelikhan <[email protected]>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/04d764a4-b984-43c6-a10f-b599f2dc3c16 Co-authored-by: pelikhan <[email protected]>
There was a problem hiding this comment.
Pull request overview
Fixes push_repo_memory failures (spawnSync git ENOBUFS) on very large repositories by avoiding git commands that emit per-file output into spawnSync pipe buffers.
Changes:
- Removes
git sparse-checkout disablefrom thepush_repo_memoryflow. - Replaces orphan-branch cleanup from
git rm -r -f --ignore-unmatch .togit read-tree --empty+ filesystem cleanup viafs.rmSync. - Adds a regression test and fixes a pre-existing Vitest import issue (
afterEach).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| actions/setup/js/push_repo_memory.cjs | Avoids ENOBUFS by clearing the index with read-tree --empty and cleaning the working directory without piping large git output. |
| actions/setup/js/push_repo_memory.test.cjs | Imports afterEach and adds a regression test asserting the new buffer-safe approach is used. |
| .changeset/patch-fix-push-repo-memory-enobufs.md | Adds a patch changeset documenting the ENOBUFS fix and rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
|
Hey This PR looks well-aligned with the project's contribution guidelines and ready for maintainer review. 🎉
|
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6196ba4a-7a62-44ff-b23b-4c8c8e73f86e Co-authored-by: pelikhan <[email protected]>
Fixed in b32815d — Prettier wanted single quotes for the mixed-quote string |
|
@copilot add more runtime checks to ensure that the branch name is compliant to the naming constraints (memory/...) and that the git fetch failure was due to a missing branch and not a temporary network issue or auth problem. |
…sh_repo_memory Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7d303137-957c-4667-8f44-3b2c52d21660 Co-authored-by: pelikhan <[email protected]>
Done in 5eed9f2. Two runtime checks added:
Tests: 2 runtime tests for the branch-name constraint, 1 runtime test asserting auth/network fetch failures surface as |
|
@copilot validate code changes with the safe output specifications |
… wiki branches Agent-Logs-Url: https://github.com/github/gh-aw/sessions/087aba65-8394-4a98-810a-fba7e414747f Co-authored-by: pelikhan <[email protected]>
Validated in 07de838. The previous
The corrected runtime check now mirrors the compiler's contract: const isNamespaced = /^[a-zA-Z0-9_-]+\/.+/.test(branchName); // covers memory/*, campaigns/*, etc.
const isKnownWikiBranch = branchName === "master" || branchName === "main" || branchName === "gh-pages";
if (!isNamespaced && !isKnownWikiBranch) { core.setFailed(...); }Added four new tests: two runtime tests (invalid bare name, |
|
@copilot |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6e49b546-3cd0-44b4-a5fe-9e48fa2b0b38 Co-authored-by: pelikhan <[email protected]>
Done in 9929054. Added if (isKnownWikiBranch && !isWikiRepo) {
core.setFailed(
`ERR_VALIDATION: Branch name "${branchName}" is only valid for wiki repositories (TARGET_REPO must end with ".wiki", got "${targetRepo}")`
);
return;
}The compiler always appends |
The Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…0-4323-8aa2-14990521f749 Co-authored-by: pelikhan <[email protected]>
push_repo_memoryfails withspawnSync git ENOBUFSon repos with 10K+ files (e.g. Azure/azure-sdk-for-js). The orphan branch setup calledgit sparse-checkout disable(materialising the full working tree) thengit rm -r -f --ignore-unmatch .withstdio: "pipe", which streams arm 'path'line per file—overflowing spawnSync's pipe buffer.Changes
Remove
git sparse-checkout disable— unnecessary for both orphan branch creation and memory branch checkout; memory branches contain only a handful of files regardless.Replace
git rm -r -f --ignore-unmatch .with buffer-safe alternatives:git read-tree --empty— resets the index to an empty tree in O(1) with zero outputfs.rmSyncloop — cleans the working directory without any pipeAdd branch name validation —
BRANCH_NAMEis validated at runtime against the naming constraints enforced by the Go compiler:{prefix}/{id}) are accepted, supporting the defaultmemory/prefix and any valid custombranch-prefix(e.g.campaigns/metrics)master,main,gh-pages) are accepted as bare names, but only whenTARGET_REPOends with.wiki— the compiler always appends.wikifor wiki memory, so this cross-validation catches any mismatch (e.g. passingmasteragainst a non-wiki repo is rejected withERR_VALIDATION)ERR_VALIDATIONerror immediately, before any git or repo operationsAdd fetch error discrimination — the
catch (fetchError)block now inspects the git error message and only falls through to orphan-branch creation when git reports a canonical "missing branch" error (couldn't find remote ref/remote branch .* not found). Authentication failures, network errors, and any other unexpected fetch failures are re-thrown so the outer handler callscore.setFailedinstead of silently creating an orphan branch.Add regression test asserting
sparse-checkout disable,git rm -r -f, andexecGitSync(["rm"are absent, andread-tree --empty+fs.rmSyncare present.Fix pre-existing test failure:
afterEachwas used but not imported from vitest.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.