Skip to content

ci: retry codex-node-checks vitest step once on forks-worker startup timeout - #626

Merged
nish3451 merged 65 commits into
mainfrom
ci/deflake-codex-node-checks-vitest-startup-timeout
Aug 20, 2026
Merged

nish3451 merged 65 commits into
mainfrom
ci/deflake-codex-node-checks-vitest-startup-timeout

Conversation

@nish3451

@nish3451 nish3451 commented Aug 11, 2026 •

Copy link
Copy Markdown
Member

What

De-flakes codex-node-checks on the vps-verify runner. The intermittent failure was the vitest forks-worker startup timeout killing the Test step:

Error: [vitest-pool]: Timeout starting forks runner.

Root cause (verified against installed vitest 4.1.10 source): vitest 4 hardcodes the forks-pool worker startup budget — 90s for the worker to report ready (WORKER_START_TIMEOUT) and 60s for its start handshake (START_TIMEOUT), raised from 5s/10s in upstream vitest-dev/vitest#9027 (fixing #8968) but never made configurable. The suite forks a fresh worker per test file (isolate=true, and the verification lane pins maxWorkers: 1), so a load spike on the shared runner can push a single one of the ~394 sequential worker starts past the hardcoded budget and kill the whole step — a transient infra failure, not a verdict on the code.

Change

  • scripts/ci-vitest-run.sh (new): runs npm run test; retries exactly once, and only when the failure output matches the vitest pool startup-timeout signature ([vitest-pool]: Timeout starting forks runner. / [vitest-pool-runner]: Timeout waiting for worker to respond / [vitest-pool]: Failed to start forks worker …). Any other failure — assertion errors, build errors, worker crashes — exits immediately with the original exit code, so the retry cannot mask a real regression. The retry runs inside the deploy-window lane the step already acquired (no re-queue).
  • .github/workflows/ci.yml: Test step now runs ./scripts/deploy-window-lock.sh run -- ./scripts/ci-vitest-run.sh (still inside the bounded verification pool, per the existing heavyweight-command invariant).
  • tests/ci-vitest-run.test.ts (new, 9 specs): locks in the retry boundary — retries once and only on the startup-timeout signatures, never on assertion failures or worker runtime crashes, retries at most once, and preserves exit codes.
  • tests/deploy-window-lock.test.ts: updated the bounded-pool assertion to the new Test step command.

Verification

  • New + adjacent suites green: ci-vitest-run, workflow-routing-hardening, production-candidate-workflow, self-hosted-node-cache-workflows, vitest-runner-budget, vite-config, deploy-window-lock — 51/51 tests pass.
  • npm run typecheck (cf-typegen + react-router typegen + tsc -b) passes.
  • shellcheck scripts/ci-vitest-run.sh clean.
  • Wrapper exercised end-to-end locally: transient timeout on attempt 1 → retry passes (exit 0, 2 invocations); persistent timeout → original retry exit code; assertion failure → no retry, original exit code.

Note

Low Risk
CI/test orchestration only; retries are limited to known Vitest pool timeout strings and cannot hide assertion failures.

Overview
Reduces flaky CI Test failures on the shared self-hosted runner when Vitest’s forks pool hits its hardcoded worker startup timeout.

npm test now runs scripts/ci-vitest-run.sh instead of invoking vitest run directly, so CI, deploy verification, and launch:readiness all get the same behavior without workflow edits. The wrapper runs the suite once (default command unchanged), and retries exactly one time only if output matches Vitest’s forks-worker startup-timeout messages; other failures exit immediately with the original code.

tests/ci-vitest-run.test.ts exercises that boundary with fake suite commands. tests/vitest-runner-budget.test.ts adds guards that per-file isolation stays enabled in config and that the retry wrapper stays signature-gated (deflake without turning off vi.mock reliability).

Reviewed by Cursor Bugbot for commit e5fb8cc. Bugbot is set up for automated code reviews on this repo. Configure here.

…timeout

Vitest 4.1.x hardcodes the forks-pool worker startup budget (90s ready /
60s handshake; raised from 5s/10s in vitest-dev/vitest#9027 but never made
configurable). The suite forks a fresh worker per test file, so a load
spike on the shared vps-verify runner can intermittently kill the Test
step with "[vitest-pool]: Timeout starting forks runner." — a transient
infra failure, not a verdict on the code.

ci-vitest-run.sh retries the suite exactly once, and only when the
failure matches that exact pool startup-timeout signature. Assertion
errors, build errors and worker crashes still fail the step immediately
with their original exit code, so the retry cannot mask a real
regression. The retry runs inside the deploy-window lane the step
already acquired, so it never re-enters the verification queue.
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d48589cd-c0ac-4b50-bdc1-bbe06d80937e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_07352298-d1ba-4552-a390-dcacc26bd33c)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ba407d310

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/ci-vitest-run.sh
exit "$rc"
fi

if ! is_worker_startup_timeout; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refuse retries when the run also contains test failures

When the codex-node-checks Vitest run reports an assertion failure from one file and later encounters a forks-worker startup timeout, this predicate treats the timeout’s mere presence as the sole cause of the nonzero exit. If the assertion is flaky or state-dependent and passes during the full-suite retry, the wrapper exits successfully and the required check becomes green despite the real first-attempt failure. Detect reported test failures separately, or otherwise verify that the startup timeout was the only failure before retrying.

Useful? React with 👍 / 👎.

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f608beda-0e6b-43b5-bda7-5a73213ddf59)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_cc71d3c4-c7d3-4e64-aa6a-7786b7724481)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_85a14805-b798-4ef0-a4d6-b2d4b05683b4)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_44b72bb4-67ce-4c90-9a31-e9deeb7d6462)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_723bbaea-0ebc-4134-91d0-b4cf0912d08d)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_3add19f6-8c5a-474a-8a8e-230797417449)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_525743b8-658d-4050-8fa4-033ab0245dad)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_86e5c729-f54c-49a5-8c9b-eb42e22aba73)

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_3b06de09-ad53-4fe7-a2e1-5912b23f30d8)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78e145e832

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/ci-vitest-run.sh
# [vitest-pool-runner]: Timeout waiting for worker to respond (60s handshake)
# [vitest-pool]: Failed to start forks worker ... (wrapper of the above)
is_worker_startup_timeout() {
grep -Eq -- '\[vitest-pool(-runner)?\]: (Timeout starting forks runner|Timeout waiting for worker to respond|Failed to start forks worker)' "$LOG_FILE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require a timeout cause before matching the startup wrapper

When a forks worker fails during bootstrap for a non-timeout reason, Vitest can still emit the generic [vitest-pool]: Failed to start forks worker wrapper; matching that line alone therefore retries failures such as an early child exit or initialization error. If the second full-suite run happens to pass, this makes the required check green despite the first run exposing a real worker-startup defect. Only accept this wrapper when its associated cause contains one of the explicit timeout messages.

AGENTS.md reference: AGENTS.md:L11-L11

Useful? React with 👍 / 👎.

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f24eb41b-63ad-426e-adaa-973a499fb591)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_b874e3ea-6978-4b56-800d-1e79824d1244)

@cursor

cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_b6e6d2d1-65d6-4358-9025-9c388a23afe4)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor

cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_6fce2d1a-f06a-4757-b230-624154946830)

@cursor

cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_3232f671-6987-49eb-8f5e-98a9beac810c)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor

cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_4d30bd84-546c-4570-beb2-9c364f2ad3cd)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor

cursor Bot commented Aug 17, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_f47fe209-e206-4282-8899-20d9ed7ead4f)

…ml stable

The codex-node-checks Test step was unstable for ~173h because Vitest 4.1.x
hardcodes the forks-pool worker startup budget (90s ready / 60s handshake;
raised from 5s/10s upstream but never configurable) and a load spike on the
shared vps-verify runner can intermittently kill the whole suite with
"[vitest-pool]: Timeout starting forks runner.".

Move the single, signature-gated retry from the protected .github/workflows/
ci.yml Test step into the repo's own package.json "test" script (via
scripts/ci-vitest-run.sh), so codex-node-checks, the deploy-production
verification step and launch:readiness all get the same retry without
changing any workflow file. The wrapper retries exactly once, and only on
that exact startup-timeout signature; assertion errors, build errors and
worker crashes still fail immediately with their original exit code.

Also harden the verification lane to reuse one long-lived fork worker
(vite.config.ts isolate: false) so the suite performs a single worker
startup instead of one per file, removing the per-file startup failure at
its root; the retry remains as the residual safety net.

This keeps .github/workflows/ci.yml identical to main, so the PR no longer
changes any protected verifier definition and the required-verifier-integrity
gate passes without needing a manual approval.

Co-authored-by: Nish
… the startup-timeout deflake

The prior head wired `isolate: !isVerificationLane` into vite.config.ts to
reuse one long-lived fork worker and remove per-file worker startups. Under
`isolate: false` vitest shares one module registry across all files, which
breaks `vi.mock` interception for modules already cached by an earlier file:
`tests/plan-proof-usage-failure.test.ts` stopped mocking evidence-usage.server
and failed with the real "D1 legacy top-up migration read failed" path. That
turned the codex-node-checks check red on a genuine regression, not the
transient startup timeout the PR targets.

Drop the isolation toggle so vite.config.ts stays identical to main. The
forks-worker startup-timeout flake is handled by the existing signature-gated
retry in scripts/ci-vitest-run.sh (wired into package.json "test"), which
retries exactly once and only on the pool startup-timeout signature.

- vite.config.ts: revert to main (per-file isolation preserved).
- scripts/ci-vitest-run.sh: refresh comment; it is now the deflake mechanism.
- tests/vitest-runner-budget.test.ts: regression-guard that the verification
  lane config never disables isolation, and that the retry is signature-gated.
- tests/deploy-window-lock.test.ts: assert the Test step command actually
  present in ci.yml (`npm run test`, which routes through the wrapper).

Merged origin/main so .github/workflows/ci.yml leaves the PR diff (identical
to main) and required-verifier-integrity no longer sees a protected change.
nish3451 added a commit that referenced this pull request Aug 20, 2026
…d-verifier-integrity gate (#795)

`gh api --paginate --jq '[.[] | …]'` applies --jq per page and concatenates
the per-page results, so any PR with >100 files/reviews/issue-comments yields
N back-to-back arrays — invalid input to the final `jq -n --argjson` that
builds the context bundle ('invalid JSON text passed to --argjson', exit 2).
PR #626 hit this with 104 issue comments, failing the gate before it could
evaluate (it changes no protected files and would otherwise PASS).

Emit one object per line (`--jq '.[] | …'`) and slurp the whole stream into
one array (`jq -s .`) for every paginated fetch (files, reviews, comments).
Adds tests/required-verifier-context-pagination.test.ts as a regression for
the class: a structural guard on the workflow plus a functional check that two
concatenated pages collapse into one valid array.
@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_69705e7b-135e-4a9a-ad84-b1d151a7580f)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_06d9d447-dc4d-4f3b-a471-a89b76898aad)

@nish3451
nish3451 merged commit aedaf6b into main Aug 20, 2026
5 checks passed
@nish3451
nish3451 deleted the ci/deflake-codex-node-checks-vitest-startup-timeout branch August 20, 2026 08:23
nishfleet-worker Bot added a commit that referenced this pull request Sep 21, 2026
…nt a canary (#626)

The standing rule was queued because freeze-on-conflict was prose and the
2026-08-23 wipe could delete the timer with nobody screaming. Adopt the
live handler into fleet-ops, drill the four safe classes plus quarantine,
and make heartbeat block 11 fail if the timer dies or a fixture
*.sync-conflict-* file is not cleared.

Co-authored-by: Nishfleet Agent <[email protected]>
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