šŸ› fix(pariksha): doc-references reports why lychee exited when it exits before reading its list

Merged
AT
10d ago
+31-4

Slice: #269
State: #308

#303 fixed the CI flake in "runs lychee from PATH when it is given no runner" on the test side: its stand-in lychee now reads its stdin. This pull request fixes the runner that test exercises, so the outcome no longer depends on whether lychee reads its input.

What changes (packages/pariksha/src/doc-links.ts): lycheeRunner hands lychee the file list on stdin (--files-from -). When lychee exits before reading it, spawnSync reports EPIPE, but still returns lychee's exit status and stderr (checked on Node 24: error.code EPIPE, status 3, stderr intact). The runner threw those away and failed with a bare spawnSync lychee EPIPE. Now:

  • an early exit with a failing status reports lychee exited N: <stderr>, as any other failed run does;
  • an early exit with 0 or 2, the statuses that would pass, fails with lychee exited N before it read its file list, so not every file was checked: …. An unread list is never a pass.

A real lychee that exits at once, on a flag or a config it refuses, reaches this path once the list outgrows the pipe, and lost the message that said why.

Proof (packages/pariksha/src/doc-links.test.ts): three new cases give a stand-in that never reads stdin a list of about 1.1 MB, past any pipe buffer, so every run hits EPIPE.

  • On the old runner all three fail with spawnSync …/lychee EPIPE, the error CI saw.
  • With the fix they passed 50 runs out of 50 on macOS. CI's Linux run is the first on Linux.
  • The stand-in exits at once, so the large input cannot hang the sync spawn (docs/lessons/testing.md): the pipe closes and the write fails fast.

pnpm --filter @veda-hq/pariksha check is green after merging main (#303 included): 3910 tests, doc-links.ts at 100% lines, branches and functions. cli.test.ts does not change. Only pariksha's runner and its tests change, and there is no version bump: a merge publishes nothing.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes the pariksha doc-references runner so it reports why lychee exited when lychee exits before reading its file list.

When lychee exits before reading the file list passed on stdin, spawnSync reports EPIPE but still returns lychee's exit status and stderr. The runner previously discarded those and failed with a bare spawnSync lychee EPIPE.

  • A failed early exit now reports lychee exited N: <stderr>, matching any other failed run.
  • An early exit with status 0 or 2 – statuses that would otherwise pass – now fails, since lychee never saw every file.
  • Adds tests with a stand-in lychee that never reads stdin and a list large enough to overflow the pipe buffer.