Repository navigation
fix(plugins): release startup-only service references - #148175
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. Reviewed September 14, 2026, 10:57 PM ET / September 15, 2026, 02:57 UTC (Revision 10). ClawSweeper reviewWhat this changesSeparates plugin-service startup references from long-lived service handles and increases the retention test’s garbage-collection budget. Merge readiness✅ Ready for maintainer review The fix remains useful beyond the earlier merged retention repair, and no blocking defect was found in the introduced changes. The previous review recorded no findings; this review identifies no additional required action. Priority: P2 Review scores
Verification
How this fits togetherThe plugin service lifecycle owner starts background services from the active plugin registry and returns handles used for reload and shutdown. Those handles must retain active service resources without keeping completed startup callbacks or retired generations alive. flowchart TD
A[Plugin registry and configuration] --> C[Prepare current service owner]
B[Previous service handle] --> C
C --> D[Publish new handle]
D --> E[Release publication callback]
E --> F[Start plugin services]
F --> G[Reload and shutdown handle]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +40, Tests +3. Total +43 across 2 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one lifecycle owner while ensuring long-lived handles cannot retain predecessor handles or completed publication callbacks. Do we have a high-confidence way to reproduce the issue? The source identifies two focused GC scenarios and the PR reports before/after failures and recovery under custom Bun. Independent current-main reproduction was not established during this read-only review. Is this the best way to solve the issue? Yes. Separating the startup activation and clearing its one-shot callback directly addresses the reported retention mechanism without adding another lifecycle owner or changing supported caller behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e903d3ece751. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
1fd3247 to
4d6d57d
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
4d6d57d to
d8b46dd
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
d8b46dd to
221841a
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
221841a to
b9dc141
Compare
|
@clawsweeper automerge |
|
🦞✅ Source: What merged:
Automerge notes:
The automerge loop is complete. Automerge progress:
|
b9dc141 to
61fbf99
Compare
|
@clawsweeper automerge |
61fbf99 to
5699742
Compare
|
@clawsweeper automerge |
Summary: - Separates plugin-service startup references from long-lived service handles and increases the retention test’s garbage-collection budget. Automerge notes: - PR branch already contained follow-up commit before automerge: test(plugins): allow GC convergence in retention proof Validation: - ClawSweeper review passed for head 5699742. - Required merge gates passed before the squash merge. Prepared head SHA: 5699742 Review: openclaw#148175 (comment) Co-authored-by: Peter Steinberger <[email protected]> Approved-by: steipete
What Problem This Solves
Plugin service handles intentionally keep only the current generation alive. The existing code avoids syntactic references to the predecessor handle and one-shot
onHandlecallback, but an engine may retain the entire async activation environment for the returned handle closures. Under Bun, every retired handle and registry stayed reachable across reloads, and the publication callback kept its captured payload alive. Node released both.This is visible in the existing retention contract: the unowned control collects and the newest handle remains usable, while Bun retains 16 completed generation objects or the publication payload.
Why This Change Was Made
Resolve and transfer predecessor ownership in a synchronous wrapper whose activation ends before any long-lived closure is created. Pass only the prepared current owner into the async lifecycle implementation. Keep the publication callback in a small holder and clear it immediately after publishing the handle, before service startup can yield.
The public function signature, Promise return, startup order, transfer policy, timeouts, error handling, and live handle ownership remain unchanged. The retention child now permits 32 full collections for released async frames to converge; the broken owner still retains every old object after 100 collections, so this does not mask a live reference.
User Impact
Long-running Gateways can reload plugin services without retaining completed service generations or data captured only for initial handle publication, on both Bun and Node.
Evidence
node scripts/check-changed.mjs: passed on the rebased head, including core/test types, lint, formatting, boundaries, dead exports, and import-cycle guards.