diff --git a/changelog.d/fixes/8844-tracked-artifacts-ls-files-buffer.md b/changelog.d/fixes/8844-tracked-artifacts-ls-files-buffer.md new file mode 100644 index 0000000000..e6c649307d --- /dev/null +++ b/changelog.d/fixes/8844-tracked-artifacts-ls-files-buffer.md @@ -0,0 +1 @@ +- **CI**: `check:tracked-artifacts` raises the `git ls-files` stdout ceiling to 64 MiB — the default 1 MiB `execFileSync` buffer had only ~6 KB of headroom against the tracked tree, and overflowing it throws ENOBUFS in the pre-commit hook, breaking `git commit` for everyone working the repo diff --git a/scripts/check/check-tracked-artifacts.mjs b/scripts/check/check-tracked-artifacts.mjs index a0324fc168..dddca935d1 100644 --- a/scripts/check/check-tracked-artifacts.mjs +++ b/scripts/check/check-tracked-artifacts.mjs @@ -51,8 +51,17 @@ export function checkTrackedArtifacts(trackedFiles, trackedSymlinks = []) { return violations; } +/** + * `execFileSync` defaults to a 1 MiB stdout buffer and throws ENOBUFS past it. + * This check runs on pre-commit, so crossing that line breaks committing for + * the whole repo, not just the change that crossed it. `git ls-files -s` is + * already at ~1.04 MB here and only grows, so the ceiling is set far above any + * plausible tree instead of just above today's. + */ +const GIT_LS_OPTS = { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }; + function getTrackedFiles() { - const output = execFileSync("git", ["ls-files"], { encoding: "utf8" }); + const output = execFileSync("git", ["ls-files"], GIT_LS_OPTS); return output .split("\n") .map((l) => l.trim()) @@ -62,7 +71,7 @@ function getTrackedFiles() { function getTrackedSymlinks() { // git ls-files -s prints: \t // mode 120000 = symlink - const output = execFileSync("git", ["ls-files", "-s"], { encoding: "utf8" }); + const output = execFileSync("git", ["ls-files", "-s"], GIT_LS_OPTS); const symlinks = []; for (const line of output.split("\n")) { if (line.startsWith("120000")) {