Skills

Openclaw Test Heap Leaks

Investigate `pnpm test` memory growth, Vitest worker OOMs, and suspicious RSS increases...

Install

npx skills add SafeAI-Lab-X/ClawKeeper --skill openclaw-test-heap-leaks -g -a claude-code -y
Category
Testing
Updated
3mo ago
License
See repository
Context cost
Lightabout 1,078 tokens
Runs scripts
Yes, review before use

What it does

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, distinguish transformed-module retention from real data leaks, and fix or reduce the impact by patching cleanup logic or isolating hotspot tests.

OpenClaw Test Heap Leaks

Use this skill for test-memory investigations. Do not guess from RSS alone when heap snapshots are available.

Workflow

  1. 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=1 enabled 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.
  2. Wait for repeated snapshots before concluding anything.

    • Take at least two intervals from the same lane.
    • Compare snapshots from the same PID inside one lane directory such as .tmp/heapsnap/unit-fast/.
    • Use scripts/heapsnapshot-delta.mjs to compare either two files directly or the earliest/latest pair per PID in one lane directory.
  3. 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 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.
Read the whole SKILL.md on GitHub

More in Testing