Skip to content

fix(tests): deflake qa-lab process-group pid-file waits - #126351

Merged
steipete merged 1 commit into
mainfrom
steipete/confident-colden-a2158e
Aug 19, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/confident-colden-a2158e

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes a flaky CI failure where the qa-lab test "kills aborted catalog process groups when the catalog child exits first" intermittently failed on loaded runners (run 32231699569, job checks-node-changed-extensions-config-37, 2026-08-19) with a Number.isInteger(descendantPid) assertion on a NaN pid.

Why This Change Was Made

The failure signature (NaN assertion rather than a wait timeout) shows the pid file existed but read back empty: the catalog child's writeFileSync exposes an open-truncate window, so an existence-based waitForFile can win between the child's open and write and parse "" into NaN. The 2s wait ceilings were additionally flaky-by-construction for spawning a real node CLI plus a grandchild under CI load. The same hazards were hand-rolled twice in qa-lab (model-catalog.runtime.test.ts and test-file-scenario-command-lifecycle.test.ts); core's test/helpers/process-wait.ts already documents and solves this bug class but is not importable across the extension boundary.

This change adds a qa-lab-local process-wait.test-helper.ts (waits on the asserted state — a parseable pid — with generous 10s deadlines and self-diagnosing timeout errors) and consolidates both test files onto it. It also retires the stale < 1_700ms abort-settle ceiling, which was calibrated against a 1.5s in-plugin kill grace deleted when the runtime moved to runCommandWithTimeout (300ms tree grace); the new 5s bound still proves abort settles with the exiting descendants rather than a long fixed kill ceiling.

User Impact

None at runtime — test-only change. CI stops flaking on this suite; future timeouts self-diagnose ("file missing" vs. the unparsable content last seen) instead of failing on an opaque NaN assertion.

Evidence

  • node scripts/run-vitest.mjs extensions/qa-lab/src/model-catalog.runtime.test.ts extensions/qa-lab/src/test-file-scenario-command-lifecycle.test.ts — 2 files, 12/12 tests passed.
  • pnpm tsgo:extensions:test, scripts/run-oxlint.mjs on touched files, git diff --check — all clean.
  • Autoreview (Codex, gpt-5.6-sol, high): clean, no actionable findings.
  • Production LOC delta: 0 (all changes are tests/test support; net test-support ≈ +8 after deleting the two duplicated helper trios).

The model catalog abort test waited for pid-file existence, but the
catalog child's writeFileSync exposes an open-truncate window: the
test could read the file empty and fail on a NaN pid assertion
(CI run 32231699569, checks-node-changed-extensions-config-37).

Add a qa-lab-local process-wait test helper that waits for the
asserted state (a parseable pid) with generous 10s deadlines and
self-diagnosing timeout errors, and consolidate the two hand-rolled
helper copies in model-catalog.runtime.test.ts and
test-file-scenario-command-lifecycle.test.ts onto it. Also retire
the stale 1.7s abort-settle ceiling (calibrated against a removed
1.5s in-plugin kill grace) in favor of a 5s bound with the contract
documented.
@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 19, 2026 16:08
@steipete
steipete merged commit 0abc513 into main Aug 19, 2026
165 of 174 checks passed
@steipete
steipete deleted the steipete/confident-colden-a2158e branch August 19, 2026 16:56
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
)

The model catalog abort test waited for pid-file existence, but the
catalog child's writeFileSync exposes an open-truncate window: the
test could read the file empty and fail on a NaN pid assertion
(CI run 32231699569, checks-node-changed-extensions-config-37).

Add a qa-lab-local process-wait test helper that waits for the
asserted state (a parseable pid) with generous 10s deadlines and
self-diagnosing timeout errors, and consolidate the two hand-rolled
helper copies in model-catalog.runtime.test.ts and
test-file-scenario-command-lifecycle.test.ts onto it. Also retire
the stale 1.7s abort-settle ceiling (calibrated against a removed
1.5s in-plugin kill grace) in favor of a 5s bound with the contract
documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant