API reference › @evolu/common › LeakDetector › LeakDetector
Defined in: packages/common/src/LeakDetector.ts:26
Detects handles that are garbage-collected while still considered held.
A handle such as a Lease must be explicitly cleaned up. Nothing in JavaScript
enforces that, so a handle whose last reference is dropped without cleanup
leaks silently. Garbage collection proves the leak: once the handle is
unreachable, no code can ever clean it up. A LeakDetector observes collection
with FinalizationRegistry and warns when the collected handle was still
held — a proven leak with zero false positives, pointing at the tracking
site.
Detection is best-effort: garbage collection timing is not deterministic, so a warning may come late or, in short-lived processes, never. It is a development canary, not a guarantee. Production uses noopLeakDetector.
Extended by
Properties
track
readonly track: (target: object, leak: Leak, unregisterToken: object) => void;
Defined in: packages/common/src/LeakDetector.ts:35
Starts tracking target until untrack or
garbage collection.
When target is garbage-collected and Leak.isLeaked returns true,
the leak is reported with the stack captured at this call. The leak must
not reference target, or the target would never become unreachable.
untrack
readonly untrack: (unregisterToken: object) => void;
Defined in: packages/common/src/LeakDetector.ts:38
Stops tracking the target registered with unregisterToken.