Repository navigation
fix(test): expose full GC for portable retention checks - #195064
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 Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR adds portable full garbage collection and WeakRef assertions to shared retention helpers and exposes GC in Node test processes. Example: A retention fixture runs in a Node Vitest worker.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR provides useful test infrastructure, and no concrete introduced defect was found. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe test runner constructs runtime arguments, Vitest starts workers, and shared retention fixtures collect objects before checking their WeakRefs. flowchart LR
A[Test invocation] --> B[Shared Node argument owner]
B --> C[Runtime selection]
C --> D[Vitest workers]
D --> E[Shared retention helper]
E --> F[Node GC or Bun GC]
F --> G[WeakRef assertions]
Technical reviewBest possible solution: Keep portable collection and runtime flags in their existing shared owners, preserving the declared separation from caller migrations. Do we have a high-confidence way to reproduce the issue? Current-main source shows the Node-only GC requirement and missing shared exposure flag; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch uses the existing owners, preserves existing collection budgets and subprocess defaults, and retains the independent routing assertions without unnecessary new machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9b8aa392679f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +29, Other 0. Total +29 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 8, 2026, 1:52 AM ET / 06:52 UTC. |
Keep the runtime capability check in the existing retention helper. Node test processes expose GC while Bun keeps its current argv and uses Bun.gc(true). Add instance-level retention assertions without changing the existing collector budget, and let Node eval fixtures request explicit runtime arguments.
Run the independent TypeScript AST oracle through the real-Node test helper while preserving planner coverage on each Vitest runtime. TypeScript synchronous IPC requires Node pipe handles. Remove the test-line allocation now that the support change has no net test-line growth.
55bdd38 to
b25bb5a
Compare
|
Merged via squash.
|
) * fix(test): expose full GC for portable retention checks Keep the runtime capability check in the existing retention helper. Node test processes expose GC while Bun keeps its current argv and uses Bun.gc(true). Add instance-level retention assertions without changing the existing collector budget, and let Node eval fixtures request explicit runtime arguments. * fix(test): isolate native compiler oracle on Node Run the independent TypeScript AST oracle through the real-Node test helper while preserving planner coverage on each Vitest runtime. TypeScript synchronous IPC requires Node pipe handles. Remove the test-line allocation now that the support change has no net test-line growth. * fix(test): collect retention checks from native callbacks
What Problem This Solves
Retention tests need a full-GC primitive that works without V8 heap inspection, and Node test workers currently do not expose
globalThis.gc.User Impact
This changes test infrastructure only. Caller migrations follow separately.
Why This Change Was Made
Extend the existing retention helper with
Bun.gc(true)/ exposed Node GC, specific-instance WeakRef assertions, and an explicit collection budget. Existing collector users retain eight passes; instance-count assertions use one. Collection runs inside the native immediate callback: collecting from a promise continuation can retain a completed caller in JavaScriptCore even after a full GC. The existing Node-argument owner adds--expose-gcunconditionally, so the existing Bun argument filter removes it. Node eval fixtures can request their own arguments through their existing helper. The independent compiler-based routing oracle runs through that real-Node helper because TypeScript’s synchronous IPC requires Node pipe handles; the planner under test still runs on each selected runtime.Reference: oven-sh/bun#46709
Evidence
Verified on head
b25bb5ae2ad47e1494c06090ee289f7aa1673c01:git diff origin/main -- src/test-utils/node-process.test.tsis empty (main60b66097c5a6b39f40924a081e20c16842e11dc5). The actual-process probe was temporary and is absent from the PR.Rebased onto the merged declaration repair from fix(ai): preserve OpenAI types in packed declarations #195098. The complete PR patch is byte-identical across the base update, so the local runtime proof is reused. Exact-head CI run 42461542237 passed on
b25bb5ae2ad47e1494c06090ee289f7aa1673c01.Actual before/after process captures passed on Node 26.12.1, stock Bun
2596ac5d3, and the pinned fork191755ec1, in the same checkout. Each probe ran inside a real Vitest test and spawned a child throughnode-process.ts.On both Buns, the top-level command, worker
execArgv/argv, and childexecArgv/argvare byte-identical. Node adds only--expose-gcto the top-level command. The measuredexecNodeEvalSyncchild is real Node even when Vitest runs on Bun. DirectcreateNodeEvalArgsconsumers that chooseprocess.execPathcan spawn Bun; their unchanged default options add no GC flag.Five real retention suites reject all eight deliberately retained test cases on Node, stock and fork; the same five restored suites pass all 64 tests on each runtime with the final native-callback helper (Node 62.97s, fork 49.95s, stock 52.70s and 42.90s on the required repeat). Areas: embedded attempt callbacks, plugin service runners, gateway scheduler callers, live-text delivery runs and browser import-state stores.
The WebSocket consumer also rejects both deliberate strong-reference cases on all three runtimes, then passes all 12 tests after release on Node, fork and two stock runs, with the original two collections.
Isolated strict typecheck of both support modules, the tooling test typecheck, formatting, and Codex review pass. The test-line ratchet passes with zero net test-line growth. The three existing runner/argument suites pass on Node and the pinned fork; the repaired full routing suite also passes on stock Bun (111 tests).
--expose-gcbefore the CLISHA-256 of the actual captured argv values, before and after
Hashes include full, unshortened paths. Worker/child values include both
execArgvandargv; process IDs are not argv and are excluded.ac56b433e975b62fbbf3a80dfbbfaffaf1c29e8b0c69bc7c020287d5108af2e4628cd4d57deb329a1868278d127e7ddace5e86bd0ea26d6361a431495bc75b656beff3c1329fdf9115cabe60a1a5ecdb7f58ee8aba19175ebcedeb43611881256beff3c1329fdf9115cabe60a1a5ecdb7f58ee8aba19175ebcedeb4361188125d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322adc7bca6465c7eac4e8e97ce4a7b5b717c7d6d2e924798b4234a55cf4bb94f86adc7bca6465c7eac4e8e97ce4a7b5b717c7d6d2e924798b4234a55cf4bb94f864253aa44dbdb3183e9d5a69d0cf52924dc5d46d03a96fd0b3fd641d16de5ba8a4253aa44dbdb3183e9d5a69d0cf52924dc5d46d03a96fd0b3fd641d16de5ba8ad917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a3220231e97f75456a121ceb7e90bb1367bb730d747b9ee879ead5b44b5ead3386ad0231e97f75456a121ceb7e90bb1367bb730d747b9ee879ead5b44b5ead3386ad44a157e2b9fce14c038c728641e787f0ad0175e11e92f55b7373c3887b3b24ba44a157e2b9fce14c038c728641e787f0ad0175e11e92f55b7373c3887b3b24bad917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322d917f3b116b01d735d2cf86cdefbaf635bd8caacce4ed84caa7e3212ee10a322The actual-process probe was repeated after the native-callback correction: Node 3.14s, stock 2.62s, fork 2.58s. All captured argv values equal the original after captures above. These short runs prove argument routing, not a performance claim.
Matched five-suite Node timing in one checkout (64 tests, both runs pass): 61.94s before → 56.48s after, 8.8% lower wall time. The original queryObjects test files and migrated files use the same common support dependencies. A separate matched WebSocket run passes all 12 tests at 5.46s before → 2.79s after. Each is one measurement pair, not a statistical benchmark.
No new test cases or net counted test lines were added in this support PR.