Skip to content

test: run the WebSocket payload-lifetime test on Node's exact GC - #35388

Merged
nwparker merged 1 commit into
mainfrom
nwparker/ws-inbound-gc-node
Oct 28, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/ws-inbound-gc-node

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 0 0 0 0
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

A WebSocket test checks that finished messages are freed from memory, by forcing garbage collection and seeing whether 80 large buffers are gone. Unit tests run under Bun, whose garbage collector sometimes keeps one object alive just because a stale value on the stack looks like a pointer to it. One buffer survived now and then, and the test failed. The test now runs on Node, whose collector is exact; Orca's main process runs on Node.

What Changed

Before: ws-inbound-message-queue.test.ts › "releases 80 completed payloads while a later conversion is blocked" failed at random under Bun: expected [ { ref: WeakRef{}, … } ] to have a length of +0 but got 1 (#35330, job 123097375791).

After: the file is listed in NODE_RUNTIME_INCLUDE (config/scripts/vitest-node-runtime-files.mjs), so it runs in the node-runtime project. That is where this repo already sends tests that measure retention (the *retention* glob and the explicit list).

Why

The test asserts something only an exact collector can promise: no remaining references means collected. JavaScriptCore, Bun's engine, scans the stack conservatively, so a leftover stack slot or register can keep one buffer reachable. That depends on timing and stack layout, which is why it fails rarely and only on loaded CI runners. V8's forced gc() is exact, and V8 is the engine the queue runs on in Electron.

Alternatives considered:

  • Allowing "at most one survivor" would hide a real leak of one payload.
  • Retrying GC rounds wouldn't help, because the stale stack slot can persist.

Other GC tests: similar tests under src/shared (own-retained-string, abort-signal-reason-memory, ndjson-retained-chunk-memory) still run under Bun. They haven't failed, and moving them isn't part of this fix.

Flag-off: test routing only.

User-risk: none.

Linked Issue

CI flake triage (unit shards blocking merges).

Visual Proof

N/A. Test-only.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • The file now runs as |node-runtime| and passes 3 runs in a row.

  • ci-shard-assignment.test.mjs and node-server-change-scope.test.mjs, which read this registry, pass (115 tests).

  • The Bun failure did not reproduce locally in 12 runs; it needs a loaded runner. The fix removes the engine that allows it rather than relying on timing.

Checks run: pnpm tc, pnpm run typecheck:ci, pnpm run check:code-quality:changed, anti-slop oxlint, oxlint, ast-grep scan and gates.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The test needs --expose-gc, which the node-runtime project already passes.

Status

Ready for review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-routing change appears safe to merge.

Summary

Moves ws-inbound-message-queue.test.ts to Node through NODE_RUNTIME_INCLUDE.

  • The WebSocket lifetime test now runs with Node's garbage collector.

Reviews (1) · Last reviewed commit: "test: run the WebSocket payload-lifetime..." · Reviewed by Greptile

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: ready. Head 6a2ad2a. CI-flake fix from the unit-shard triage; load rule run locally (pnpm tc, typecheck:ci, code-quality, anti-slop, oxlint, ast-grep scan and gates) plus the affected tests. Review requested from e9-reviewer. Not merged.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f34b65f-2882-4dd8-8187-4c289cecaa2e
Commits

Reviewing files that changed from the base of the PR and between c66d873 and 6a2ad2a.

Files selected for processing: 1
  • config/scripts/vitest-node-runtime-files.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

The Node-runtime test include list now includes src/shared/ws-inbound-message-queue.test.ts. A comment notes that Bun’s conservative stack scanning may keep a collected payload alive.

Priority: Low

Merge Risk: Minimal · up to 6a2ad

This test-only routing change does not introduce user or production risk and is ready to merge.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: routing the WebSocket payload-lifetime test to Node's garbage collector.
Description check Passed The description is complete and focused. It explains the problem, change, reason, alternatives, testing, risk, and checklist status. The Linked Issue section describes CI flake triage but does not inc…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description is complete and focused. It explains the problem, change, reason, alternatives, testing, risk, and checklist status. The Linked Issue section describes CI flake triage but does not include an issue link, which is a minor template gap.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches: 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 1510f46 into main Oct 28, 2026
56 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant