openclaw-test-heap-leaks

Diagnose Vitest worker memory growth by comparing V8 heap snapshots across test lanes.

Updated Mar 30, 2026
One-click install
npx skills add https://github.com/srgaba/open-claw --skill openclaw-test-heap-leaks-srgaba
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: openclaw-test-heap-leaks
Source: https://github.com/srgaba/open-claw/tree/main/project/.agents/skills/openclaw-test-heap-leaks
Command: npx skills add https://github.com/srgaba/open-claw --skill openclaw-test-heap-leaks-srgaba

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Test suites that grow in memory until Vitest workers hit out-of-memory errors are hard to diagnose from RSS numbers alone. This Skill provides a repeatable workflow to reproduce memory growth in OpenClaw's pnpm test runs, capture periodic .heapsnapshot files, and determine whether growth comes from retained transformed modules in long-lived workers or from genuine application-level leaks. ## Core Features & Use Cases - Heap Snapshot Delta Analysis: The bundled heapsnapshot-delta.mjs script compares two snapshots directly or auto-selects the earliest/latest snapshots per PID within a lane directory, reporting top retained object families by size and count delta. - Leak Classification Workflow: Guides you to distinguish Vite/Vitest transformed-module retention (strings, Module, bytecode, descriptor arrays) from real leaks (caches, buffers, timers, DB handles, mock state) before choosing a fix. - Targeted Remediation: For module-graph growth, isolate hotspot files via singletonIsolated in test/fixtures/test-parallel.behavior.json; for real leaks, patch missing afterEach/afterAll cleanup, module resets, or unreleased handles. - Use Case: A CI unit-test lane OOMs at 6GB. You rerun with OPENCLAW_TEST_HEAPSNAPSHOT_INTERVAL_MS=60000, compare snapshots from the same worker PID in .tmp/heapsnap/unit-fast, find growth dominated by transformed source strings from two files missing from timings, and move them to isolated lanes to stop the OOM. ## Quick Start Ask the agent to reproduce the test memory growth with heap snapshots enabled and compare snapshots from the same worker PID to identify whether the growth is a real leak or retained module graph.

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 diagnose Vitest worker out-of-memory errors?

Reproduce the failing lane with heap snapshots enabled by setting OPENCLAW_TEST_HEAPSNAPSHOT_INTERVAL_MS and OPENCLAW_TEST_HEAPSNAPSHOT_DIR, then compare at least two snapshots from the same worker PID. The heapsnapshot-delta.mjs script reports the top retained object families driving the growth.

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

Run node heapsnapshot-delta.mjs before.heapsnapshot after.heapsnapshot to diff two files directly, or pass --lane-dir to auto-select the earliest and latest snapshots per PID. Flags like --top, --min-kb, and --pid control the output.

Why does test memory grow even without a real leak?

Long-lived Vitest workers retain Vite-transformed source strings, Module objects, bytecode, and descriptor arrays as more test files load into the shared worker. This is worker-lifetime module graph growth, not an application leak, and is best fixed by isolating hotspot files into separate lanes.

When should I isolate a test file instead of fixing a leak?

Isolate a file when snapshot deltas are dominated by transformed-module artifacts rather than runtime objects like caches, buffers, timers, or DB handles. Move it to singletonIsolated in test/fixtures/test-parallel.behavior.json, especially if it is missing from the timings fixture.

What if heap snapshots make tests too slow to finish?

Snapshot overhead can push tests past Vitest timeouts. In that case, rerun the same lane without snapshots and confirm the RSS trend or OOM is reduced, using OPENCLAW_TEST_MEMORY_TRACE=1 per-file RSS summaries as the fallback signal.