Stop concurrent test packs from rewriting the shared build (pm-vcs-v5bg)

Merged
UN
8d ago
+90-17

Fixes #175. Tracker: pm-vcs-v5bg

Problem

installPackedExtension (scripts/pm-environment.ts) ran npm pack --silent in the package root.

  • npm pack runs prepack, which is npm run build (tsc). That build truncates and rewrites dist/.
  • The release suite runs up to four test files concurrently. One file's tsc rewrote dist/ while another file's npm pack was archiving it, and node-tar failed with EOF: encountered unexpected EOF.
  • --silent hid that npm error. The test diagnostic showed only the prepare script's harmless npm pack: skipping merge-driver install during artifact creation line.

Where it failed:

RunJobTest
main at 131dc3atest (22)bisect.test.ts: "a walk killed mid-flight resumes…"
#177test (26)checkpoints.test.ts: "installed CLI attaches and inspects JSON and TOON…"

Locally, 3 of 60 and then 5 of 60 staggered concurrent packs failed. Each failure was npm error code EOF, syscall read, on a dist/ file: dist/engine/lifecycle.js, dist/ledger.js and dist/engine/destruction.js.map.

Change

  • Pack with --ignore-scripts. test/composition-consumer.test.ts and scripts/verify-pack-privacy.ts already do this. Every runner builds before packing: test, coverage, release:check, and the Windows job's npm run build step. This helper was the only thing that rewrote dist/ during the suite.
  • Replace --silent with --loglevel=error. A future pack failure then reports npm's own error.
  • Add a regression test in test/quality-scripts.test.ts. A real npm pack must leave every dist/ file's mtime unchanged.

Verification

  • The new test passes with the fix. With the old --silent arguments restored, it fails because the dist/ mtimes change.
  • Stress test with the new arguments: 0 of 60 staggered concurrent packs failed, and stderr was empty.
  • typecheck, lint, docstring, duplicates, changelog:check and accept:self-host (at HEAD) pass.
  • test/quality-scripts.test.ts: 10 of 10 pass.
  • The self-host bundle was regenerated for the new tracker item.

Summary by Sourcery

Make concurrent package creation reuse the existing build while surfacing actionable npm pack failures.

Bug Fixes:

  • Prevent concurrent test packs from rebuilding and rewriting the shared dist/ directory, eliminating intermittent npm pack EOF failures.
  • Expose npm pack errors and whether the process exited by status or signal in installation diagnostics.

Enhancements:

  • Ensure the native TOON acceptance workflow builds before packing so it can reuse the existing build.

Tests:

  • Add regression coverage confirming packing preserves dist/ file modification times and reports pack failures, npm errors, missing executables, and terminated processes.

Chores:

  • Regenerate the self-host bundle for the tracker update.

Summary by cubic

Fixes flaky EOF: encountered unexpected EOF failures when concurrent test files pack the same package root. installPackedExtension ran npm pack --silent, whose prepack step rebuilt dist/ while another test process was archiving it, and --silent hid npm's error.

The pack now uses --ignore-scripts to reuse the existing build (every runner builds first) and --loglevel=error so npm failures surface.

  • accept:native-toon now builds first via preaccept:native-toon, matching the other acceptance scripts, since the pack no longer rebuilds.
  • A failed pack now names how the child ended: npm pack failed (status N): <npm error> or npm pack failed (signal S).
  • Tests cover the regression (a real pack leaves every dist/ mtime unchanged), a missing executable, a refused pack carrying npm's error text, and a SIGKILL.