openclaw-test-heap-leaks

Diagnose Vitest test memory growth by diffing V8 heap snapshots per worker PID.

1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/JEROME-PRAKASH-L/openclaw --skill openclaw-test-heap-leaks-jerome-prakash-l
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openclaw-test-heap-leaks
Source: https://github.com/JEROME-PRAKASH-L/openclaw/tree/main/.agents/skills/openclaw-test-heap-leaks
Command: npx skills add https://github.com/JEROME-PRAKASH-L/openclaw --skill openclaw-test-heap-leaks-jerome-prakash-l

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Investigating pnpm test OOMs and RSS spikes in the OpenClaw repo is hard because Vitest worker memory growth can come from either real application leaks or retained transformed-module graphs in long-lived shared workers. This Skill provides a repeatable workflow to reproduce the failing lane, capture heap snapshots, and classify the growth before choosing a fix. ## Core Features & Use Cases - Heap Snapshot Diffing: Compare two .heapsnapshot files directly or auto-select the earliest/latest pair per PID inside a lane directory using the bundled heapsnapshot-delta.mjs script. - Leak Classification Heuristics: Distinguish retained Vite/Vitest transformed-module growth from genuine runtime object leaks, with guidance to confirm ambiguous cases via DevTools retainers and dominators. - Fix Guidance: Apply timing-driven scheduling fixes, singletonIsolated lane peeling via test-parallel behavior fixtures, or patch real cleanup gaps such as missing afterEach hooks and unreleased handles. - Use Case: A CI unit-fast-batch lane OOMs at 6GB. Reproduce with OPENCLAW_TEST_HEAPSNAPSHOT_DIR enabled, diff snapshots per PID, find transformed-module strings dominating the delta, and peel the hotspot file into an isolated lane. ## Quick Start Ask the agent to investigate the OpenClaw test memory growth by reproducing the failing lane with heap snapshots enabled and diffing the snapshots with the heapsnapshot-delta script.

Frequently Asked Questions about openclaw-test-heap-leaks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I investigate Vitest out-of-memory errors in pnpm tests?

Reproduce the failing lane with OPENCLAW_TEST_MEMORY_TRACE=1 and OPENCLAW_TEST_HEAPSNAPSHOT_DIR set so workers write periodic heap snapshots. Then diff the earliest and latest snapshots per PID with the heapsnapshot-delta.mjs script to see which object families grew.

How do I compare two V8 heap snapshots from the command line?

Run node heapsnapshot-delta.mjs before.heapsnapshot after.heapsnapshot, optionally with --top and --min-kb filters. You can also pass --lane-dir to auto-select the earliest and latest snapshot pair for a worker PID in one directory.

Is Vitest memory growth always a real application leak?

No. In shared long-lived workers, growth dominated by transformed source strings, Module objects, or bytecode usually indicates retained module-graph growth rather than an app leak. Confirm ambiguous cases by inspecting retainers and dominators in Chrome DevTools before labeling it.

How do I reduce memory in a shared Vitest worker lane?

First refresh timing-driven scheduling via the test-timings fixture and memory hotspot manifest. If a hotspot file still inflates shared workers, move it out using the test-parallel behavior fixture, preferring singletonIsolated for files that are safe to run alone.

Can this approach validate runtime closure leaks outside of tests?

Yes, but use the dedicated pnpm leak:embedded-run harness instead of the test-parallel snapshot machinery. It loops aborted runs, tracks instances with FinalizationRegistry, and reports a PASS/FAIL verdict on retention growth.