fix-disposable-leak

Diagnose and fix Disposable memory leaks in a TypeScript Electron editor codebase.

Updated May 13, 2026
One-click install
npx skills add https://github.com/lovebirdsx/universe-editor --skill fix-disposable-leak-lovebirdsx
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: fix-disposable-leak
Source: https://github.com/lovebirdsx/universe-editor/tree/main/.claude/skills/fix-disposable-leak
Command: npx skills add https://github.com/lovebirdsx/universe-editor --skill fix-disposable-leak-lovebirdsx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Memory leaks from undisposed Disposable objects are hard to trace: leak reports contain transformed stack traces, paired entries, and false positives from reload timing. This Skill provides a systematic workflow to interpret DisposableTracker leak reports, locate the creation point that missed registration, apply the minimal fix, and add regression tests. ## Core Features & Use Cases - Leak report analysis: Decode idx pairs, creation stacks, and report sources to distinguish real leaks from false positives (e.g., reload-path React subscription misreports). - Guided fix patterns: Apply the correct remedy per leak type — _register / DisposableStore.add for service instances, useEffect cleanup for React subscriptions, and synchronous disposal for exit-path resources. - Regression testing: Write cascade-disposal assertions or use the withLeakCheck / useLeakCheck helpers, then verify the test fails without the fix. - Use Case: When the dev console prints "Disposable leak(s) detected" with a stack pointing at lifecycle.ts, use this Skill to trace the owning service, find the creation path missing _register, fix it, and validate with vitest. ## Quick Start Ask the AI to diagnose the Disposable leak report you pasted and fix the missing registration in the owning service.

Frequently Asked Questions about fix-disposable-leak

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

FAQPage Schema
How do I fix a Disposable memory leak reported by DisposableTracker?▼

Read the leak stack bottom-up to find the owning class, then compare sibling creation paths to find the one missing _register or DisposableStore.add. Register the leaked instance on its owner, add a regression test asserting cascade disposal, and verify with vitest.

Why does one leaked Disposable show up as two entries in the report?▼

The Disposable base class creates an internal DisposableStore in its constructor, so a leak reports both the object and its _store with consecutive idx values. Treat the pair as a single object, not two separate bugs.

Why are React useEffect subscriptions reported as leaks on window reload?▼

The reload path historically ran computeLeakingDisposables before React unmounted, so all active subscriptions were false positives. Reports tagged [renderer:reload] with clustered useEffect subscriptions indicate a detection-timing issue, not real leaks.

Does holding a disposable in a closure prevent the leak report?▼

No. Referencing a disposable inside a closure like () => foo.dispose() does not build a parent chain, so the object is still reported. You must actually call _register or DisposableStore.add, or explicitly dispose it.

Why do e2e leak checks fail when disposal is deferred with setTimeout?▼

The e2e leak gate takes a synchronous snapshot, so a setTimeout-deferred disposal has not run yet and the store is judged as leaked. Use queueMicrotask instead, which drains within the current turn before the snapshot.