Summary
In resilient-eventsource.ts, the connect() method assigns onmessage, onopen, and onerror handlers directly on a new EventSource instance. However, if connect() is called again during reconnection, the previous EventSource may not have all listeners properly cleaned up before the new one is created.
While close() is called on the old instance (which should remove listeners), the pattern is fragile — if close() doesn't fire synchronously or the browser implementation differs, listeners could accumulate.
Suggested Fix
Explicitly remove event handlers before closing:
private disconnect(): void {
if (this.es) {
this.es.onmessage = null;
this.es.onopen = null;
this.es.onerror = null;
this.es.close();
this.es = null;
}
}
Files Affected
dashboard/src/api/resilient-eventsource.ts (lines 35-69)
Severity
Warning — Potential memory leak on repeated reconnections.
Generated by Hephaestus (Aegis dev agent)
Summary
In
resilient-eventsource.ts, theconnect()method assignsonmessage,onopen, andonerrorhandlers directly on a newEventSourceinstance. However, ifconnect()is called again during reconnection, the previousEventSourcemay not have all listeners properly cleaned up before the new one is created.While
close()is called on the old instance (which should remove listeners), the pattern is fragile — ifclose()doesn't fire synchronously or the browser implementation differs, listeners could accumulate.Suggested Fix
Explicitly remove event handlers before closing:
Files Affected
dashboard/src/api/resilient-eventsource.ts(lines 35-69)Severity
Warning — Potential memory leak on repeated reconnections.
Generated by Hephaestus (Aegis dev agent)