openclaw-test-heap-leaks
Skill325 starsChanged 7 months agoMITView on GitHub
Investigate `pnpm test` memory growth, Vitest worker OOMs, and suspicious RSS increases in OpenClaw using the `scripts/test-parallel.mjs` heap snapshot tooling. Use when Codex needs to reproduce test-lane memory growth, collect repeated `.heapsnapshot` files, compare snapshots from the same worker PID, triage likely transformed-module retention versus likely runtime leaks, and fix or reduce the impact by patching cleanup logic or isolating hotspot tests.
We split this skill into the rules it gives an agent
20 rules. 6 are common, 5 are distinctive, and 9 are very specific to this project.
6
Common
Most of the 12 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 8
Use this skill for test-memory investigations.
- Very specific: line 15
Keep OPENCLAW_TEST_MEMORY_TRACE=1 enabled so the wrapper prints per-file RSS summaries alongside the snapshots.
- Distinctive: line 16
If the report is about a specific shard or worker budget, preserve that shape.
- Very specific: line 17
Before you analyze snapshots, identify the real lane names from [test-parallel] start ...
- Distinctive: line 19
Wait for repeated snapshots before concluding anything.
- Very specific: line 22
Use .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs to compare either two files directly or the earliest/latest pair …
- Distinctive: line 23
If the helper suggests transformed-module retention, confirm the top entries in DevTools retainers/dominators before calling it solved.
- Very specific: line 26
If growth is dominated by Vite/Vitest transformed source strings, Module, system / Context, bytecode, descriptor arrays, or property maps, …
- Common: line 27
If growth is dominated by app objects, caches, buffers, server handles, timers, mock state, sqlite state, or similar runtime objects, treat …
- Common: line 28
If the names are ambiguous, stop short of a confident label and inspect retainers/dominators in DevTools for the top deltas.
- Very specific: line 32
Prefer timing and hotspot-driven scheduling fixes first.
- Very specific: line 34
Prefer singletonIsolated for files that are safe alone but inflate shared worker heaps.
- Very specific: line 35
If the file should already have been peeled out by timings but is absent from test/fixtures/test-timings.unit.json, call that out …
- Very specific: line 38
Look for missing afterEach/afterAll, module-reset gaps, retained global state, unreleased DB handles, or listeners/timers that survive the …
- Common: line 40
Verify with the most direct proof.
- Distinctive: line 42
If snapshot overhead pushes tests over Vitest timeouts, fall back to the same lane without snapshots and confirm the RSS trend or OOM is …
- Very specific: line 47
Do not call everything a leak.
- Distinctive: line 50
When one or two files account for most of the delta and they are missing from timings, reducing impact by isolating them is usually the …
- Common: line 51
When the same retained object families grow across multiple intervals in the same worker PID, trust the snapshots over intuition, then …
- Common: line 68
When using this skill, report:
“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
OpenClaw Test Heap Leaks
Use this skill for test-memory investigations. Do not guess from RSS alone when heap snapshots are available. Treat snapshot-name deltas as triage evidence, not proof, until retainers or dominators support the call.
Workflow
- Reproduce the failing shape first.
- Match the real entrypoint if possible. For Linux CI-style unit failures, start with:
pnpm canvas:a2ui:bundle && OPENCLAW_TEST_MEMORY_TRACE=1 OPENCLAW_TEST_HEAPSNAPSHOT_INTERVAL_MS=60000 OPENCLAW_TEST_HEAPSNAPSHOT_DIR=.tmp/heapsnap OPENCLAW_TEST_WORKERS=2 OPENCLAW_TEST_MAX_OLD_SPACE_SIZE_MB=6144 pnpm test- Keep
OPENCLAW_TEST_MEMORY_TRACE=1enabled so the wrapper prints per-file RSS summaries alongside the snapshots. - If the report is about a specific shard or worker budget, preserve that shape.
- Before you analyze snapshots, identify the real lane names from
[test-parallel] start ...lines orpnpm test --plan. Do not assume a singleunit-fastlane; local plans often split intounit-fast-batch-*.
- Wait for repeated snapshots before concluding anything.
- Take at least two intervals from the same lane.
- Compare snapshots from the same PID inside the real lane directory such as
.tmp/heapsnap/unit-fast-batch-2/. - Use
.agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjsto compare either two files directly or the earliest/latest pair per PID in one lane directory. - If the helper suggests transformed-module retention, confirm the top entries in DevTools retainers/dominators before calling it solved.
- Classify the growth before choosing a fix.
- If growth is dominated by Vite/Vitest transformed source strings,
Module,system / Context, bytecode, descriptor arrays, or property maps, treat it as likely retained module graph growth in long-lived workers. - If growth is dominated by app objects, caches, buffers, server handles, timers, mock state, sqlite state, or similar runtime objects, treat it as a likely cleanup or lifecycle leak.
- If the names are ambiguous, stop short of a confident label and inspect retainers/dominators in DevTools for the top deltas.
- If growth is dominated by Vite/Vitest transformed source strings,
- Fix the right layer.
- For likely retained transformed-module growth in shared workers:
- Prefer timing and hotspot-driven scheduling fixes first. Check whether the file is already represented in
test/fixtures/test-timings.unit.jsonand whetherscripts/test-update-memory-hotspots.mjsshould refresh the measured hotspot manifest before hand-editing behavior overrides. - Move hotspot files out of the real shared lane by updating
test/fixtures/test-parallel.behavior.jsononly when timing-driven peeling is insufficient. - Prefer
singletonIsolatedfor files that are safe alone but inflate shared worker heaps. - If the file should already have been peeled out by timings but is absent from
test/fixtures/test-timings.unit.json, call that out explicitly. Missing timings are a scheduling blind spot. - For real leaks:
- Patch the implicated test or runtime cleanup path.
- Look for missing
afterEach/afterAll, module-reset gaps, retained global state, unreleased DB handles, or listeners/timers that survive the file.
- Verify with the most direct proof.
- Re-run the targeted lane or file with heap snapshots enabled if the suite still finishes in reasonable time.
- If snapshot overhead pushes tests over Vitest timeouts, fall back to the same lane without snapshots and confirm the RSS trend or OOM is reduced.
- For wrapper-only changes, at minimum verify the expected lanes start and the snapshot files are written.
Heuristics
- Do not call everything a leak. In this repo, large
unit-fastorunit-fast-batch-*growth can be a worker-lifetime problem rather than an application object leak. scripts/test-parallel.mjsandscripts/test-parallel-memory.mjsare the primary control points for wrapper diagnostics.- The lane names printed by
[test-parallel] start ...and[test-parallel][mem] summary ...tell you where to focus. - When one or two files account for most of the delta and they are missing from timings, reducing impact by isolating them is usually the first pragmatic fix.
- When the same retained object families grow across multiple intervals in the same worker PID, trust the snapshots over intuition, then confirm ambiguous calls with retainer evidence.
Snapshot Comparison
- Direct comparison:
node .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs before.heapsnapshot after.heapsnapshot
- Auto-select earliest/latest snapshots per PID within one lane:
node .agents/skills/openclaw-test-heap-leaks/scripts/heapsnapshot-delta.mjs --lane-dir .tmp/heapsnap/unit-fast-batch-2
- Useful flags:
--top 40--min-kb 32--pid 16133
Read the top positive deltas first. Large positive growth in module-transform artifacts suggests lane isolation; large positive growth in runtime objects suggests a real leak. If the names alone do not settle it, open the same snapshot pair in DevTools and inspect retainers/dominators for the top rows before declaring root cause.
Output Expectations
When using this skill, report:
- The exact reproduce command.
- Which lane and PID were compared.
- The dominant retained object families from the snapshot delta.
- Whether the issue is a likely real leak or likely shared-worker retained module growth, plus whether retainers/dominators confirmed it.
- The concrete fix or impact-reduction patch.
- What you verified, and what snapshot overhead prevented you from verifying.
Other versions13 projects use a version of this.
Word for word · 1
- OpenBMB/EdgeClaw★ 1.2k100% same
Edited · 12
- moltbot/moltbot★ 393k33% same
- clawdbot/clawdbot★ 393k33% same
- steipete/warelay★ 392k33% same
- moltbot/clawdbot★ 392k33% same
- steipete/clawdis★ 392k33% same
- molt-bot/clawdbot★ 391k33% same
- openclaw/openclaw★ 391k33% same
- friuns2/openclaw-android-assistant★ 55633% same
- OpenClawAndroid/openclaw-android-assistant★ 55633% same
- bighamx/openclaw-android-node-apk★ 5933% same
2 more not listed
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- extensions/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- extensions/CLAUDE.mdCLAUDE.md
- openclaw-ghsa-maintainerSkill
- openclaw-parallels-smokeSkill
- openclaw-pr-maintainerSkill
- openclaw-qa-testingSkill
- openclaw-release-maintainerSkill
- parallels-discord-roundtripSkill
- security-triageSkill
- update-openclaw-bundleSkill
- 1passwordSkill
- apple-notesSkill
- apple-remindersSkill
- bear-notesSkill
- blogwatcherSkill
- blucliSkill
- bluebubblesSkill
- camsnapSkill
- canvasSkill
- clawhubSkill
- coding-agentSkill
- discordSkill
- eightctlSkill
- geminiSkill
- gh-issuesSkill
- gifgrepSkill
- githubSkill
- gogSkill
- goplacesSkill
- healthcheckSkill
- himalayaSkill
- imsgSkill
- mcporterSkill
- model-usageSkill
- nano-pdfSkill
- node-connectSkill
- notionSkill
- obsidianSkill
- openai-whisper-apiSkill
- openai-whisperSkill
- openhueSkill
- oracleSkill
- ordercliSkill
- peekabooSkill
- sagSkill
- session-logsSkill
- sherpa-onnx-ttsSkill
- skill-creatorSkill
- slackSkill
- songseeSkill
- sonoscliSkill
- spotify-playerSkill
- summarizeSkill
- taskflow-inbox-triageSkill
- taskflowSkill
- things-macSkill
- tmuxSkill
- trelloSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

