Skip to content

fix(ci): read the changed-path list past the first pipe buffer - #19409

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-pr-scope-stdin-64k
Sep 8, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-pr-scope-stdin-64k

Conversation

@nwparker

@nwparker nwparker commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​48
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

ELI5

The PR Checks gate reads its list of changed files from stdin with one readFileSync(0). When that list is bigger than a pipe buffer, the read returns early, the script exits 0 having printed nothing, and every lane it gates gets silently skipped instead of failing. Stream stdin instead.

Why now

PR #13178 hit this. GitHub gave it a pull_request.base.sha of bb09dc17 — 1,592 commits behind current main, because the PR was opened long ago and later refreshed onto main. The gate's merge-base diff therefore produced 13,294 files / 773,461 bytes instead of that PR's actual 4 files, and blew past the 64 KB pipe buffer.

Result on #13178: detect code-relevant changes failed on all 3 attempts (never a flake), verify cascaded (CODE_PATHS: failure), and these 16 lanes were skipped, not run:

typecheck, test, static analysis, xterm patch sync, package, package (windows), e2e, shell contracts, Git compatibility, cross-version wire compatibility, real IME, real WSL terminal, orcad browser provider, Codex index-heal contract, managed hooks on Node 18, prepare test native cache

The remaining green checks came from unrelated workflows, so the PR read as "mostly green" while none of its own validation had executed. That silent-skip is the part worth fixing: the failure mode is invisible rather than loud.

What changed

config/scripts/pr-code-change-scope.mjs now streams process.stdin — the exact pattern its sibling config/scripts/pr-e2e-source-routing.mjs already uses for the same list in the same workflow step. No classification logic changed; no workflow YAML changed.

Evidence

Threshold bisected on the real failing input — a clean pipe-buffer boundary:

stdin before
58,822 bytes OK
70,116 bytes EAGAIN: resource temporarily unavailable, read
773,461 bytes (#13178's actual gate input) EAGAIN

After the fix, the 773 KB input classifies correctly. The real 4-file #13178 diff and the docs-only short-circuit (README.md → should_run=false) classify byte-identically to before.

Testing

  • New regression test classifies a path that arrives after the first pipe buffer: feeds >64 KB through a real pipe with a slow writer, with the only code-relevant path placed last. Verified red against the old script (expected 'node:fs:441...' not to contain 'EAGAIN') and green after.
  • Test is portable — uses spawn, not a shell pipeline, so it runs on the Windows lane too. Note spawnSync({input}) does not reproduce the bug (it hands the child a blocking fd 0); the slow-writer pipe does.
  • config/scripts/pr-code-change-scope.test.mjs 31/31; pr-e2e-source-routing, pr-workflow-lint-parity, pr-e2e-gate-contract, pr-workflow-parallelism pass.
  • oxlint, oxfmt, changed-code quality gate clean.

Follow-up not in this PR

This makes the gate robust to a large list; it does not make the list correct. A stale base.sha still over-triggers lanes (safe direction — it runs more, not fewer). Narrowing the diff to the true merge base against the base branch tip is a separate change.

`pr-code-change-scope.mjs` read stdin with `readFileSync(0, 'utf8')`, a single
read of fd 0. Once the writer outgrows the 64 KB pipe buffer that read returns
early or throws EAGAIN, the script exits 0 having emitted no `name=value` pairs,
and `tee -a "$GITHUB_OUTPUT"` records nothing -- so every lane the classifier
gates is silently skipped rather than failing loudly.

A PR opened long ago carries a stale `pull_request.base.sha`, so the gate's
merge-base diff spans the whole base branch. PR #13178 diffed 13,294 files
(773 KB) against a base 1,592 commits behind main and lost typecheck, test,
static analysis, xterm patch sync, package and e2e to this.

Stream stdin instead, matching how the sibling `pr-e2e-source-routing.mjs`
already reads the same list in the same workflow.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • pr-code-change-scope.mjs streams stdin instead of readFileSync(0) — the CLI block now consumes process.stdin with for await, eliminating the early-read/EAGAIN failure when the changed-path list outgrows a single pipe buffer. Matches the sibling pr-e2e-source-routing.mjs idiom for the same list.
  • New regression test over a real slow-writer pipe — classifies a path that arrives after the first pipe buffer spawns the script with >64 KB written in chunks and the sole code-relevant path last, asserting exit 0, no EAGAIN/EPIPE, and correct classification. Exact final-state assertions, so it is deterministic for the fixed code.
  • Unused node:fs import removed; split('\n') tightened to split(/\r?\n/) for CRLF robustness.

The fix is correctly scoped: the streaming conversion is the established pattern the sibling script already uses, no classification logic or workflow YAML changed, and the remaining readFileSync(0) call site in this path is gone. The stale-base.sha over-triggering is explicitly deferred and fails safe (runs more, not fewer), so there is nothing blocking here.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 474fe1a8-efa1-4bfa-a3fc-39d40d19e954

📥 Commits

Reviewing files that changed from the base of the PR and between 102402e and 44c7536.

📒 Files selected for processing (2)
  • config/scripts/pr-code-change-scope.mjs
  • config/scripts/pr-code-change-scope.test.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The CLI now reads stdin asynchronously in UTF-8 chunks. It supports CRLF input and removes empty lines before classification. The test suite adds an async spawned-process test that sends more than 64 KiB of delayed path input. The test verifies successful classification and confirms that the process produces no EAGAIN or EPIPE errors.

Merge Risk: ⚪ Minimal · up to 44c75

This change prevents large changed-path lists from being truncated or skipped in PR job classification, while preserving existing path classification behavior. The large-input regression coverage indicates no current merge-blocking risk.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, relevant, and explains the problem, implementation, evidence, and testing. However, it omits the required Linked Issue section, the required Visual Proof declaration for a… Add the Linked Issue section with an issue reference, add N/A with a brief reason under Visual Proof because this is not a UI change, and complete or explicitly address the remaining required template sections and checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: reading the changed-path list beyond the first pipe buffer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is detailed, relevant, and explains the problem, implementation, evidence, and testing. However, it omits the required Linked Issue section, the required Visual Proof declaration for a non-UI change, and several template checklist sections.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit cbc7bb4 into main Sep 8, 2026
29 checks passed
@nwparker
nwparker deleted the nwparker/fix-pr-scope-stdin-64k branch September 8, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant