Skip to content

fix(test): let profiler help shut down naturally - #149010

Merged
steipete merged 2 commits into
mainfrom
codex/profiler-natural-exit-20260915
Sep 15, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/profiler-natural-exit-20260915

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #145335, #148825

What Problem This Solves

Profiler help forces process exit after writing its profile, skipping Node's normal shutdown drainage. CI has also observed help commands stall after finalization and an exit event, before the parent observes child completion.

User Impact

This affects internal developer tooling. Profiler help retains its output and profile artifacts while allowing normal shutdown work to finish.

Why This Change Was Made

Return from the asynchronous entrypoint after awaited profile finalization. Keep normal test execution, error handling, managed process cleanup, and the existing finalization-stage diagnostics intact. The help tests now require the child's beforeExit event and the expected profile count.

This is a focused extraction of @fuller-stack-dev's profiler change from #145335, with the newer diagnostics preserved.

Evidence

  • On Linux with Node 24.19.0, adding only the shutdown assertions makes all four help cases fail on the original implementation; the other 31 tests pass. With the production change, the original seven-file workload passes all 312 tests, including every profiler case.
  • Fresh baseline runs of both the original full file (35 tests) and original surrounding workload (312 tests) passed before the fix. The intermittent CI stall did not reproduce in those runs, and its native cause remains unproven.
  • The recorded CI failure completed profile stop, writing, disconnect, and an inner exit event but did not reach observed child completion. The original fix's profiler job passed all 35 profiler cases on Node 24.19.0; that overall run failed separately in UI tests.
  • Scoped changed checks and fresh P2 review passed. Managed process-group checks remain enabled; a post-run audit found no remaining profiler entrypoints. The task-owned Testbox was stopped after evidence collection.

Return after awaited profile finalization so Node can drain normal shutdown
work before exiting. Retain the finalization-stage diagnostics and verify
beforeExit, profile counts, and managed child completion.

Extract the focused profiler change from source commit
7016601 in #145335. Fresh Linux Node 24.19.0
runs preserve both nonreproductions of the intermittent CI stall; the
beforeExit contract fails before this change and passes afterward.

Co-authored-by: Jason (Json) <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Sep 15, 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: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 15, 2026, 8:41 AM ET / 12:41 UTC (Revision 3).

ClawSweeper review

What this changes

The profiler help command finishes writing its profile and lets Node shut down naturally, with regression assertions for shutdown drainage and artifact counts.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused repair: current main still forces help to exit, and no blocking patch defect was found. The maintainer-authored, protected PR is not a cleanup candidate.

Priority: P2
Reviewed head: db5faac8103e6d511c6ee87da447c4d57e0e5427

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful real-process regression coverage and no actionable correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Its reported Linux Node 24.19.0 runs exercise the actual profiler child’s drainage and artifacts; they do not establish elimination of the intermittent native stall.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Its reported Linux Node 24.19.0 runs exercise the actual profiler child’s drainage and artifacts; they do not establish elimination of the intermittent native stall.
Evidence reviewed 8 items Introduced behavior: Ignoring indentation, the production delta wraps the existing entrypoint in an async function and replaces the help branch's forced exit with return; finalization, normal execution, and error handling remain intact.
Current main still needs the change: Fetched main still calls process.exit(0) after awaited help-profile finalization.
Latest release comparison: The supplied latest release, v2026.9.4, also contains the forced help exit; this repair is not already shipped there.
Findings None None.
Security None None.

How this fits together

OpenClaw’s developer profiling wrapper launches Vitest in a managed child process and collects CPU or heap profiles. Help requests print usage and finalize any active capture before the parent observes completion.

flowchart TD
  A[Developer profiler command] --> B[Managed child process]
  B --> C{Help requested?}
  C -->|Yes| D[Print help and finalize capture]
  D --> E[Node drains and exits]
  E --> F[Parent observes completion]
  C -->|No| G[Run and profile tests]
Loading

Before merge

  • Resolve merge risk (P1) - The intermittent native shutdown stall remains unexplained; successful drainage assertions do not establish that this patch eliminates it.
Agent review details

Security

None.

PR surface

Tests +6, Other +5. Total +11 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 6 0 +6
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 76 71 +5
Total 2 82 71 +11

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the existing finalization and managed-process owners, allow natural help shutdown, and retain the separate native-stall investigation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the existing finalization and managed-process owners, allow natural help shutdown, and retain the separate native-stall investigation.

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

Yes for skipped natural shutdown: current main explicitly calls process.exit, which bypasses beforeExit, and the PR reports four failing baseline assertions. No reliable reproduction of the intermittent native stall is established.

Is this the best way to solve the issue?

Yes for the bounded shutdown contract: returning after awaited finalization preserves existing owners and avoids forced termination without changing test execution or cleanup policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against c0be265998d0.

Labels

Label justifications:

  • P2: This repairs a bounded shutdown contract in internal developer profiling tools.
  • 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: The supplied MEMBER association exempts this PR from the external-contributor proof gate. Its reported Linux Node 24.19.0 runs exercise the actual profiler child’s drainage and artifacts; they do not establish elimination of the intermittent native stall.

Evidence

What I checked:

  • Introduced behavior: Ignoring indentation, the production delta wraps the existing entrypoint in an async function and replaces the help branch's forced exit with return; finalization, normal execution, and error handling remain intact. (scripts/run-vitest-profile-child.mts:22, db5faac8103e)
  • Current main still needs the change: Fetched main still calls process.exit(0) after awaited help-profile finalization. (scripts/run-vitest-profile-child.mts:23, c0be265998d0)
  • Latest release comparison: The supplied latest release, v2026.9.4, also contains the forced help exit; this repair is not already shipped there. (scripts/run-vitest-profile-child.mts:23, 3a9d69db306c)
  • Regression boundary and reported validation: The complete test file exercises the real profiler wrapper and child with observational preloads. Four help cases require beforeExit, successful completion, usage output, and one main-profile artifact or zero runner artifacts. The captured PR body reports those assertions failing before the repair and all 312 surrounding workload tests passing afterward on Linux Node 24.19.0; these runs were not repeated during this read-only review. (test/scripts/run-vitest-profile.test.ts:563, db5faac8103e)
  • Prior review continuity: Both affected files are unchanged from the previously reviewed head. The supplied completed review has no findings or published rank-up moves. (db5faac8103e)
  • Related shutdown history: Current-main history includes the earlier error-path natural-shutdown repair. GitHub commit metadata identifies steipete, and its patch replaces the rethrow with error reporting and exitCode assignment. Deeper local follow/blame inspection encountered unavailable historical blobs; the direct commit patch was inspected through GitHub. (scripts/run-vitest-profile-child.mts:84, 716624fd3dc9)

Likely related people:

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

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-09-15T10:47:40.224Z sha ed64d66 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-15T10:55:15.527Z sha ed64d66 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 15, 2026 10:51
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 15, 2026
@steipete steipete self-assigned this Sep 15, 2026
@steipete
steipete merged commit c6d6d65 into main Sep 15, 2026
80 checks passed
@steipete
steipete deleted the codex/profiler-natural-exit-20260915 branch September 15, 2026 13:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
Return after awaited profile finalization so Node can drain normal shutdown
work before exiting. Retain the finalization-stage diagnostics and verify
beforeExit, profile counts, and managed child completion.

Extract the focused profiler change from source commit
7016601 in openclaw#145335. Fresh Linux Node 24.19.0
runs preserve both nonreproductions of the intermittent CI stall; the
beforeExit contract fails before this change and passes afterward.

Co-authored-by: Jason (Json) <[email protected]>
Finn763 added a commit to Finn763/openclaw that referenced this pull request Sep 23, 2026
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. scripts Repository scripts size: S 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