Skip to content

fix(test): collect Bun garbage outside promise microtasks - #159975

Merged
steipete merged 1 commit into
mainfrom
codex/ci-bun-gc-boundary
Sep 30, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/ci-bun-gc-boundary

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes false retention failures in Bun GC tests when collection runs inside a Promise continuation that can still retain completed async values.

User Impact

Leak regression tests collect at a stable event-loop boundary. Product behavior and the existing Node/Bun test partition remain unchanged.

Why This Change Was Made

The helper performs the same single Bun.gc(true) call directly in the native setImmediate callback, then resolves the waiting Promise. The Node path, leak assertions, collection controls, and number of collections are preserved.

Evidence

  • Original CI reports: snapshot eviction and reply-preview retirement.
  • Blacksmith verification used the checksum-pinned CI Bun fork and Node 24.19.0. All 20 runs of the three Bun-admitted consumer files passed (48 tests per run; mean 3.91 seconds wall). Existing Node-only consumers passed 258 tests.
  • Three actual partitioned UI shard replays each passed 8,157 tests across 513 files, with one existing skip.
  • Restoring the historical strong snapshot map and omitting reply-cache clearing still fails all three corresponding leak assertions with the new helper.
  • A controlled original-helper/candidate pair reproduced and fixed overview-object retention under forced Bun. That overview fixture is already assigned to Node in CI and stays there. The two original snapshot/reply failures did not reproduce in focused baseline runs; no heap-retainer capture was taken.
  • Full pinned-base selected checks and independent P0–P2 review passed. No GC retry loops, extra collections, assertion relaxations, or new runtime exemptions.
  • Current-head PR CI: run 36360624872 passed (827s workflow elapsed). Selected test-job walls: checks-ui (1/3): 323s, checks-ui (2/3): 316s, checks-ui (3/3): 330s. Job walls include setup and cleanup; standalone file timings are reported above.

@clawsweeper

clawsweeper Bot commented Sep 28, 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.

@steipete
steipete marked this pull request as ready for review September 28, 2026 00:01
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 29, 2026, 9:25 PM ET / September 30, 2026, 01:25 UTC (Revision 4).

ClawSweeper review

What this changes

The PR moves Bun garbage collection in the shared Control UI test helper into a native immediate callback, leaving the Node path and leak assertions intact.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open. Current main still collects Bun garbage from a Promise continuation, and the merged plugin-retention repair does not change this UI helper. The focused patch has no supported blocking defect.

Priority: P2
Reviewed head: 816fac81dfc2155cb7211aec7012520f5ada9f7d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused patch has relevant Bun before/after and repeated-run evidence, with the exact original failures still unreproduced.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The changed test helper is exercised by UI weak-reference retention suites. The captured PR evidence reports an old-versus-new forced-Bun retention result, repeated passing runs on the pinned CI Bun runtime, and full UI shard replays; it does not claim to reproduce the two exact original CI failures. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The changed test helper is exercised by UI weak-reference retention suites. The captured PR evidence reports an old-versus-new forced-Bun retention result, repeated passing runs on the pinned CI Bun runtime, and full UI shard replays; it does not claim to reproduce the two exact original CI failures. No stored-data contract changes.
Evidence reviewed 8 items Introduced patch: The introduced hunk moves the single Bun.gc(true) call into a native setImmediate callback and preserves the Node branch.
Current main remains unfixed: At the fetched main revision, the helper awaits the Promise-based immediate and then calls Bun.gc(true) in the resumed continuation. The latest release tag also contains this older helper.
Release check: The supplied latest release, v2026.9.6, contains the older Promise-continuation collection path, so it does not make this PR redundant.
Findings None None.
Security None None.

How this fits together

Control UI retention tests create weak references to objects used by chat, usage, and desktop views. A shared test helper forces garbage collection before those tests check whether objects were released or retained.

flowchart LR
  A[UI retention tests] --> B[Weak references]
  B --> C[Shared GC helper]
  C --> D{Test runtime}
  D -->|Bun| E[Immediate callback GC]
  D -->|Node| F[Node collection path]
  E --> G[Retention assertions]
  F --> G
Loading

Decision needed

Question Recommendation
Should the paused UI garbage-collection helper repair be merged on its current head? Accept the focused repair: Review the current head and merge the UI-only test fix if its existing Bun evidence meets the maintainer's bar.

Why: The author explicitly stopped automerge and requested human review; this review cannot reverse that pause.

Before merge

  • Complete next step (P2) - Obtain the requested human review and merge decision on the current head.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

PR surface

Tests +10. Total +10 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 13 3 +10
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 13 3 +10

Review metrics

Metric Value Why it matters
Pinned Bun repeatability 20 runs of 48 tests each reported passing Repeated runs are relevant to the intermittent retention failures this fixture addresses.

Technical review

Best possible solution:

Keep one shared UI test helper that collects at a stable Bun task boundary while preserving the existing Node behavior and weak-reference checks.

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

Unclear for the two original CI assertions: neither reproduced in focused baseline runs. The PR reports a controlled before/after Bun reproduction of the same helper's retention mechanism with an overview object.

Is this the best way to solve the issue?

Yes. Moving the existing Bun collection into the native callback is a narrow repair to the shared test helper and leaves the Node path and leak assertions intact.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change addresses intermittent UI test reliability with limited product impact.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed test helper is exercised by UI weak-reference retention suites. The captured PR evidence reports an old-versus-new forced-Bun retention result, repeated passing runs on the pinned CI Bun runtime, and full UI shard replays; it does not claim to reproduce the two exact original CI failures. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • VACInc: 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 (3 earlier review cycles)
  • reviewed 2026-09-28T00:08:41.059Z sha a15996e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T00:50:28.520Z sha a15996e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T02:57:06.315Z sha a15996e :: blocked before merge. :: none

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper automerge is enabled.

  • Head: a15996e66363
  • Label: clawsweeper:automerge
  • Action: exact-head review queued (workflow sweep.yml, event repository_dispatch).
  • Flow: review this head, repair/rebase only if needed, then re-review the exact repaired head before merge.

Draft PRs stay fix-only until GitHub marks them ready for review. Pause with /clawsweeper stop.

Automerge progress:

  • 2026-09-28 01:15:44 UTC review queued a15996e66363 (queued)

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge label Sep 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper stop

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
Got it. ClawSweeper will leave this item for human review.

I added clawsweeper:human-review, removed clawsweeper:automerge, and paused the automation trail until a maintainer asks again.

@clawsweeper clawsweeper Bot added clawsweeper:human-review Needs maintainer review before ClawSweeper can continue and removed clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 28, 2026
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member

Related companion work: #160200 applies the native-callback GC correction to the plugin-retention fixture, and #160213 incorporates it alongside a separate production disposal-retention fix. The plugin-retention suite passed 10/10 under the pinned CI Bun runtime with its collection bounds and assertions unchanged.

This PR applies the correction to the independent UI GC helper and UI tests. Those paths are not changed by #160213, so it does not supersede this PR. Keep this PR open; no UI test fix or broad production-memory resolution is being claimed by the plugin repair.

Run the existing single collection in the native immediate callback so settled async values are not conservatively rooted by the promise drain stack. Preserve Node behavior, CI runtime routing, and leak assertions. Repeated consumers, three full partitioned shards, historical leak controls, selected checks and independent review passed.
@steipete
steipete force-pushed the codex/ci-bun-gc-boundary branch from a15996e to 816fac8 Compare September 30, 2026 01:20
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit d88c559 into main Sep 30, 2026
88 checks passed
@steipete
steipete deleted the codex/ci-bun-gc-boundary branch September 30, 2026 01:55
@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 30, 2026
…59975)

Run the existing single collection in the native immediate callback so settled async values are not conservatively rooted by the promise drain stack. Preserve Node behavior, CI runtime routing, and leak assertions. Repeated consumers, three full partitioned shards, historical leak controls, selected checks and independent review passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui clawsweeper:human-review Needs maintainer review before ClawSweeper can continue P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants