-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Summary
CacheManager.startCleanupTimer() in @claude-flow/memory calls setInterval(..., 60000) without .unref(), keeping the Node.js event loop alive indefinitely. Any CLI command that touches memory (memory store, memory search, etc.) cannot exit cleanly.
Root Cause
cache-manager.js line 310:
startCleanupTimer() {
this.cleanupInterval = setInterval(() => {
this.cleanupExpired();
}, 60000);
// MISSING: this.cleanupInterval.unref();
}The CacheManager is instantiated via TieredCacheManager → this.l1Cache = new CacheManager(...) whenever the bridge initializes. Since the constructor calls startCleanupTimer(), the 60-second housekeeping interval holds the event loop open.
Other timers in the same package (agentdb-backend.js:142, auto-memory-bridge.js:534) correctly call .unref(). sqljs-backend.js:81 has the same bug with its persistTimer.
Fix
Defect MM-002 in claude-flow-patch.
Add .unref() after each setInterval call in cache-manager.js and sqljs-backend.js. Housekeeping timers should not prevent process exit — they are best-effort cleanup, not critical work.
| Op | File | Change |
|---|---|---|
| MM-002a | cache-manager.js |
Add this.cleanupInterval.unref() after setInterval |
| MM-002b | sqljs-backend.js |
Add this.persistTimer.unref() after setInterval |
Files Affected
@claude-flow/memory/dist/cache-manager.js@claude-flow/memory/dist/sqljs-backend.js
Affected Versions
ruflo (all versions)
Related Issues
- None