mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 23:49:41 +02:00
fix: memory leaks and performance optimizations
- WebServer: Store session listener refs for explicit cleanup on delete - RespawnController: Fix clearInterval bug (was using clearTimeout) - RespawnController: Add try/catch to interval callbacks - PlanOrchestrator: Guarantee progressInterval cleanup with try/finally - SubagentWatcher: Guard idle timer against deleted agents - Session: Add threshold validation for auto-clear/compact (1k-500k) - Session: Add token sum overflow check in restoreTokens - Session: Use LRUMap for _recentTaskDescriptions auto-eviction Commit from flight QR118 in an Airbus A350-1000, stable connection thanks to Starlink! Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1160,8 +1160,12 @@ export class RespawnController extends EventEmitter {
|
||||
private startDetectionUpdates(): void {
|
||||
this.stopDetectionUpdates();
|
||||
this.detectionUpdateTimer = setInterval(() => {
|
||||
if (this._state !== 'stopped') {
|
||||
this.emit('detectionUpdate', this.getDetectionStatus());
|
||||
try {
|
||||
if (this._state !== 'stopped') {
|
||||
this.emit('detectionUpdate', this.getDetectionStatus());
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`[RespawnController] Error in detectionUpdateTimer:`, err);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
@@ -1724,7 +1728,7 @@ export class RespawnController extends EventEmitter {
|
||||
this.hookConfirmTimer = null;
|
||||
}
|
||||
if (this.stuckStateTimer) {
|
||||
clearTimeout(this.stuckStateTimer);
|
||||
clearInterval(this.stuckStateTimer);
|
||||
this.stuckStateTimer = null;
|
||||
}
|
||||
// Clear all tracked timers
|
||||
@@ -1743,7 +1747,7 @@ export class RespawnController extends EventEmitter {
|
||||
|
||||
// Clear existing timer
|
||||
if (this.stuckStateTimer) {
|
||||
clearTimeout(this.stuckStateTimer);
|
||||
clearInterval(this.stuckStateTimer);
|
||||
this.stuckStateTimer = null;
|
||||
}
|
||||
|
||||
@@ -1751,7 +1755,11 @@ export class RespawnController extends EventEmitter {
|
||||
const checkIntervalMs = Math.min(this.config.stuckStateWarningMs, 60000); // Check every minute max
|
||||
|
||||
this.stuckStateTimer = setInterval(() => {
|
||||
this.checkStuckState();
|
||||
try {
|
||||
this.checkStuckState();
|
||||
} catch (err) {
|
||||
console.error(`[RespawnController] Error in stuckStateTimer:`, err);
|
||||
}
|
||||
}, checkIntervalMs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user