From 1380c3c66b9111ee6c8387138cac6545fc5d8a27 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Thu, 14 Aug 2025 08:53:36 -0500 Subject: [PATCH] Add explanatory note for LLMs around WS pool --- src/lib/data_structures/websocket_pool.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/data_structures/websocket_pool.ts b/src/lib/data_structures/websocket_pool.ts index 5efcdf5..5eda81a 100644 --- a/src/lib/data_structures/websocket_pool.ts +++ b/src/lib/data_structures/websocket_pool.ts @@ -211,6 +211,7 @@ export class WebSocketPool { } } this.#pool.clear(); + console.debug('[WebSocketPool] Pool drained successfully'); } @@ -252,6 +253,8 @@ export class WebSocketPool { this.#clearIdleTimer(handle); // Clean up event listeners to prevent memory leaks + // AI-NOTE: Code that checks out connections should clean up its own listener callbacks before + // releasing the connection to the pool. if (handle.ws) { handle.ws.onopen = null; handle.ws.onerror = null; @@ -261,7 +264,9 @@ export class WebSocketPool { const url = this.#normalizeUrl(handle.ws.url); this.#pool.delete(url); + console.debug(`[WebSocketPool] Removed socket for ${url}, pool size: ${this.#pool.size}`); + this.#processWaitingQueue(); }