Skip to content

Stopped the deploy-build simulation from racing parallel test files - #373

Merged
aileen merged 2 commits into
mainfrom
aileen/serialize-deploy-build-simulation
Nov 5, 2026
Merged

aileen merged 2 commits into
mainfrom
aileen/serialize-deploy-build-simulation

Conversation

@aileen

@aileen aileen commented Nov 5, 2026

Copy link
Copy Markdown
Member

ref #213

Problem

While delivering the page-identity work for #213, full local pnpm test:coverage runs failed roughly every second or third time in cli-content-projection.acceptance.test.ts > "replaces stale continuations with one stable record on repeated shrinking runs", on unmodified main, while the file always passed standalone. That undermined trust in the local verification gate the #213 slices rely on.

The captured failure is not a timeout. The CLI subprocess exits with:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  '.../packages/algolia-fragmenter/node_modules/@tryghost/algolia-html-extractor/dist/index.mjs'
  imported from .../packages/algolia-fragmenter/lib/index.mjs

Cause

A millisecond-resolution filesystem watcher over full suite runs shows packages/algolia-html-extractor/dist disappearing for about 1.5 seconds in every run. The deletion comes from the Netlify function-tracing test "packages the extractor on a deploy without prebuilt workspace output", which removes the extractor's gitignored dist/ to prove that a fresh Netlify clone rebuilds it during netlify build.

Vitest runs test files in parallel, so any test that spawns a new Node process inside that window cannot resolve the extractor through the fragmenter. The shrinking-runs test spawns three CLI processes back to back and has the longest exposure, and coverage instrumentation stretches both the window and the spawns, which is why coverage runs flaked most. Standalone runs never fail because the tracing file is not running at the same time.

Ruled out: the 20s/15s/5s timeouts were never hit, the replay server takes its port from the OS so there is no port contention, and the tsc builds that pack tests trigger are write-free when outputs are up to date (the existing build-output-stability test already guards that).

Fix

Vitest projects with sequence.groupOrder split the suite into two sequential groups: everything else keeps running in parallel in group 0, and the destructive tracing file runs alone in group 1. packages/algolia-netlify gets the same split for the focused pnpm --filter @tryghost/algolia-netlify test run, which had the same latent race.

No test, assertion, or timeout changed, keeping the repo's rule that tests are never weakened or skipped. The suite stays deterministic and offline; the cost is that the tracing file no longer overlaps other files, adding its own runtime (about 10s) to the total.

Verification

  • Reproduced the failure twice before the fix in an isolated standard clone of main.
  • After the fix: six consecutive full pnpm test:coverage runs passed (sanity run plus five verification runs), with the watcher confirming the dist deletion now happens only after the parallel group has finished.
  • Three consecutive pnpm --filter @tryghost/algolia-netlify test runs passed.
  • pnpm lint passes; coverage thresholds and test/verify-coverage.mjs unchanged and green.

@netlify

netlify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for alg-helpcenter ready!

Name Link
🔨 Latest commit 4ee6615
🔍 Latest deploy log https://app.netlify.com/projects/alg-helpcenter/deploys/6aec7833b805de0fa53d9617
😎 Deploy Preview https://deploy-preview-373--alg-helpcenter.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 7 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 50 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 8e5fa04c-f5d2-464b-9971-64d0bed0910c
Commits

Reviewing files that changed from the base of the PR and between b385633 and 4ee6615.

Files selected for processing: 3

  • nx.json
  • packages/algolia-netlify/vitest.config.mjs
  • vitest.config.mjs

No actionable comments were generated in the recent review.

Walkthrough

The root Vitest configuration separates the deploy-build-simulation acceptance test from the workspace tests and adds a coverage include pattern for built Algolia indexer files. The Netlify Vitest configuration also separates its function-tracing acceptance test into a later project.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: Moderate · previous review b3856

The required CI check currently fails because the Netlify project has no version plan. Resolve the check before merging.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title states the main change: the deploy-build simulation is stopped from racing parallel test files. The PR isolates the destructive function-tracing test into a sequential Vitest group, which ma…
Description check Passed The description explains the problem (intermittent ERR_MODULE_NOT_FOUND failures in coverage runs), the cause (a Netlify function-tracing test removes the extractor's dist/ directory while parallel te…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Title check

Explanation

The title states the main change: the deploy-build simulation is stopped from racing parallel test files. The PR isolates the destructive function-tracing test into a sequential Vitest group, which matches the title's subject and intent. The title is short, specific, and uses no vague terms.

Full details: Description check

Explanation

The description explains the problem (intermittent ERR_MODULE_NOT_FOUND failures in coverage runs), the cause (a Netlify function-tracing test removes the extractor's dist/ directory while parallel tests run), the fix (Vitest sequence.groupOrder splitting the suite into two groups), and verification steps. It is directly related to the changeset.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: f45d34cf-7e2b-4da1-a502-2f67ac018373
Commits

Reviewing files that changed from the base of the PR and between 68145a8 and b385633.

Files selected for processing: 2

  • packages/algolia-netlify/vitest.config.mjs
  • vitest.config.mjs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

ref #213

Full `pnpm test:coverage` runs failed intermittently in
cli-content-projection.acceptance.test.ts ("replaces stale continuations
with one stable record on repeated shrinking runs") while the same file
always passed standalone. The failing CLI subprocess exits with
ERR_MODULE_NOT_FOUND for packages/algolia-html-extractor/dist/index.mjs,
imported from the fragmenter.

A filesystem watcher over full runs showed the cause. The Netlify
function-tracing test "packages the extractor on a deploy without
prebuilt workspace output" deletes the extractor's gitignored dist/ to
prove that a fresh Netlify clone rebuilds it during `netlify build`.
That leaves every full run with a window of about 1.5 seconds in which
the extractor has no build output. Vitest runs test files in parallel,
so any test that spawns a new Node process inside the window cannot
resolve the extractor. The shrinking-runs test spawns three CLI
processes back to back and has the longest exposure, and coverage
instrumentation stretches both the window and the spawns, which is why
coverage runs flaked most. Timeouts, replay-server ports, and the
coverage subprocess attach were ruled out: the recorded failures never
hit a timeout, and the replay server takes its port from the OS.

Vitest projects now split the suite into two sequential groups. Every
other test file keeps running in parallel in group 0, and the
destructive tracing file runs alone in group 1 via sequence.groupOrder.
The netlify package gets the same split for
`pnpm --filter @tryghost/algolia-netlify test`, which had the same
latent race. No test, assertion, or timeout changed. Six consecutive
full `pnpm test:coverage` runs and three focused netlify package runs
passed after the change; before it, the suite failed roughly every
second or third run.
The plan check flagged @tryghost/algolia-netlify as touched because the
flake fix adds packages/algolia-netlify/vitest.config.mjs. Vitest configs
only shape how tests run and never ship (the package publishes dist/
alone), so they belong with the test files and markdown the check
already ignores. A version plan here would instead force a pointless
npm release and Netlify release promotion for a dev-only file.
@aileen
aileen force-pushed the aileen/serialize-deploy-build-simulation branch from 4dda46d to 4ee6615 Compare November 5, 2026 12:36
@aileen
aileen enabled auto-merge (squash) November 5, 2026 12:36
@aileen
aileen merged commit 5d3a4e7 into main Nov 5, 2026
14 checks passed
@aileen
aileen deleted the aileen/serialize-deploy-build-simulation branch November 5, 2026 12:37
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