Skip to content

fix(test): synchronize custom worker shutdown proof - #132824

Merged
vincentkoc merged 1 commit into
mainfrom
fix/vitest-shutdown-profiler-routing
Aug 29, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/vitest-shutdown-profiler-routing

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

Related: #132784

What Problem This Solves

Exact-head Node 24/Linux CI exposed a race in the intentional custom-pool shutdown proof. The custom worker wrote the fixture's ready marker from the child IPC send callback. That callback confirms the message was sent, but not that Vitest's parent-side stopped listener consumed it.

The parent preload could therefore observe ready and invoke the captured 60-second stop deadline before Vitest processed the response, producing [vitest-pool-runner]: Timeout waiting for worker to respond during an otherwise successful custom-worker teardown.

Why This Change Was Made

For the non-opt-in custom worker, the child now sends stopped without owning readiness. The parent ChildProcess wrapper first delivers the message through the existing synchronous Vitest listeners, then records stopped-consumed and writes ready.

The regression test requires that consumed-response event while preserving the existing exit-0, parent-stop, SIGTERM, no-deadline, cleanup, signal, and caller assertions.

PR #132820 independently landed the native worker profiling repair and fully absorbed this PR's original unsupported-profiler routing work. After refreshing onto current main, this branch retains only the distinct custom-worker synchronization fix.

User Impact

Maintainers get deterministic Node 24/Linux shutdown coverage for custom pools without relaxing the exit assertion, extending timeouts, or changing production behavior. This removes the CI blocker for #132784.

Evidence

  • Pre-fix exact-head CI run 33272396917: custom/raw raced the captured stop deadline before Vitest consumed stopped, causing a teardown timeout at the exit-0 assertion.
  • Post-refresh local custom repetition: 30/30 passed.
  • Post-refresh Node 24.19.0/Linux Testbox focused matrix: 12/12 passed.
  • Post-refresh sibling tooling tests: 391/391 passed.
  • Post-refresh Node 24.19.0/Linux changed gate: passed after hydrating the disposable Testbox lease.
  • Local formatting and diff checks: passed.
  • Mandatory Codex Sol/high autoreview via the standalone binary: clean, correctness 0.99.
  • Test/support LOC: +13/-2. Production LOC: +0/-0.

Testbox run:

ClawSweeper Rank-up Moves

  • Complete fresh exact-head CI and normal maintainer merge handling after the base refresh.

Provenance

The shutdown matrix landed in 0f2211294740cf855c64f09cc73bb45ce7cf0964 (#132403). Exact-head CI later exposed the custom-worker message-consumption race. PR #132820 landed the overlapping profiler-routing repair before this branch refreshed onto main.

  • AI-assisted
  • I understand the change and verified the affected behavior.
  • Autoreview completed with no actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 29, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 29, 2026 20:01
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Aug 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 29, 2026
@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 4:41 PM ET / 20:41 UTC.

ClawSweeper review

What this changes

The PR records custom-worker readiness only after the parent delivers Vitest’s stopped response, then asserts that ordering in the shutdown regression.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

The narrowed test-only repair is source-aligned with Vitest’s custom-worker shutdown contract and has no actionable review finding; keep it open for normal maintainer handling while exact-head checks complete.

Priority: P2
Reviewed head: e5fa6d1ee9c020bc2a4cb2896f828b5e6e80c328

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable test-race repair with an assertion at the relevant lifecycle boundary.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored, test-only PR is exempt from the external-contributor proof gate; its supplied focused Testbox and repeated custom-shutdown results are consistent with the reviewed fixture path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored, test-only PR is exempt from the external-contributor proof gate; its supplied focused Testbox and repeated custom-shutdown results are consistent with the reviewed fixture path.
Evidence reviewed 6 items Parent-side ordering repair: The introduced wrapper first invokes the original ChildProcess message emission, which synchronously runs registered listeners, then records stopped-consumed and writes readiness.
Child no longer owns readiness: The ordinary custom entrypoint now sends its stopped response without a send-callback readiness write; the explicit self-exiting custom-opt-in path remains separate.
Regression assertion covers the causal event: The custom scenario requires stopped-consumed as well as parent stop, no synthetic deadline, and SIGTERM termination, so the added assertion observes the intended parent-side ordering rather than child send completion.
Findings None None.
Security None None.

How this fits together

OpenClaw’s test tooling launches Vitest worker pools and records lifecycle events to prove safe shutdown behavior. This fixture models a custom worker and feeds its stop acknowledgment into the parent-side shutdown assertions.

flowchart LR
  A[Custom test worker] --> B[Stopped IPC response]
  B --> C[Parent process wrapper]
  C --> D[Vitest stopped listener]
  D --> E[Readiness marker]
  E --> F[Shutdown assertions]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: no patch defect was found, and this maintainer-associated PR should proceed through normal exact-head CI and review.
Agent review details

Security

None.

PR surface

Tests +11. Total +11 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 13 2 +11
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 13 2 +11

Review metrics

Metric Value Why it matters
Production versus test-support LOC production +0/-0; test support +13/-2 The whole delta stays in an isolated shutdown fixture and its regression assertion; no application or dependency runtime code changes.

Technical review

Best possible solution:

Land the parent-consumption ordering assertion after the required checks are green, retaining the existing custom-worker parent-owned shutdown protocol.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: current main’s custom fixture writes readiness from the child send callback before parent message consumption, while the focused shutdown scenario exercises that deadline ordering. The read-only review did not execute the fixture.

Is this the best way to solve the issue?

Yes. Moving the marker to immediately after parent-side synchronous emission records the fact the deadline depends on, and the added assertion protects that precise ordering without weakening timeouts or changing production code.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f9b3bcccdba3.

Labels

Label justifications:

  • P2: This is a bounded test-infrastructure race repair that improves CI reliability without changing production behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored, test-only PR is exempt from the external-contributor proof gate; its supplied focused Testbox and repeated custom-shutdown results are consistent with the reviewed fixture path.

Evidence

What I checked:

  • Parent-side ordering repair: The introduced wrapper first invokes the original ChildProcess message emission, which synchronously runs registered listeners, then records stopped-consumed and writes readiness. (test/fixtures/vitest-fork-shutdown.mjs:79, e5fa6d1ee9c0)
  • Child no longer owns readiness: The ordinary custom entrypoint now sends its stopped response without a send-callback readiness write; the explicit self-exiting custom-opt-in path remains separate. (test/fixtures/vitest-fork-shutdown.mjs:207, e5fa6d1ee9c0)
  • Regression assertion covers the causal event: The custom scenario requires stopped-consumed as well as parent stop, no synthetic deadline, and SIGTERM termination, so the added assertion observes the intended parent-side ordering rather than child send completion. (test/scripts/vitest-fork-shutdown.test.ts:68, e5fa6d1ee9c0)
  • Direct Vitest contract evidence: The checked-in Vitest patch explicitly leaves custom entrypoints without willExit on the parent-owned stop path; the fixture continues to model that path rather than changing the dependency contract. (patches/README.md:7, e5fa6d1ee9c0)
  • Focused test routing: The repository routes fixture changes to this isolated shutdown test, and the routing test requires that exact mapping. (scripts/test-projects.test-support.mts:550, e5fa6d1ee9c0)
  • Current-main history: Local history identifies the current-main shutdown-fixture work in merged commits f9b3bcc and 0f221129; this PR is one child commit on top of f9b3bcc and its introduced delta is limited to the two reviewed test paths. (test/fixtures/vitest-fork-shutdown.mjs:79, f9b3bcccdba3)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let required exact-head checks finish green before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-29T20:08:04.467Z sha d0de9ff :: needs maintainer review before merge. :: none
  • reviewed 2026-08-29T20:24:41.627Z sha 9e2a8f59f98fafc244eb251da8b475633f98d29e :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The head now fixes the exact-head custom-pool teardown race by marking fixture readiness only after the parent has synchronously delivered Vitest's stopped response. Assertions remain strict. Post-fix proof: custom repetition 30/30, Node 24/Linux focused 12/12, siblings 391/391, changed gate green, and Sol/high autoreview clean.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc vincentkoc changed the title fix(test): route shutdown cases around unsupported profiling fix(test): synchronize custom worker shutdown proof Aug 29, 2026
@vincentkoc
vincentkoc force-pushed the fix/vitest-shutdown-profiler-routing branch from 9e2a8f5 to e5fa6d1 Compare August 29, 2026 20:36
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The branch was refreshed onto f9b3bcccdba. PR #132820 absorbed the original profiler-routing work, so the exact head e5fa6d1ee9c now contains only the distinct custom-worker synchronization repair (+13/-2 test support): readiness is recorded after Vitest's synchronous parent-side stopped listeners consume the message. Post-refresh proof is custom 30/30, Node 24/Linux focused 12/12, siblings 391/391, changed gate green, and Sol/high autoreview clean.

@clawsweeper

clawsweeper Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant