From e9405c836125c57e90c6a97f1f5b888924c91336 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Thu, 14 Aug 2025 08:46:12 -0500 Subject: [PATCH 1/3] Lock Deno version in Dockerfile This avoids a memory leak bug in the latest version of Deno. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9bdfec7..5be0979 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM denoland/deno:alpine AS build +FROM denoland/deno:alpine-2.4.2 AS build WORKDIR /app/src COPY . . From 42cc8aa6d97bd61ec3d8a464f7a27fdcebc33f3b Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Thu, 14 Aug 2025 08:47:53 -0500 Subject: [PATCH 2/3] Revert memory limit env vars --- Dockerfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5be0979..2f09ee6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,6 @@ FROM denoland/deno:alpine-2.4.2 AS build WORKDIR /app/src COPY . . -# Set memory limits for Deno to prevent memory leaks -ENV DENO_MEMORY_LIMIT=512MB -ENV DENO_GC_INTERVAL=1000 - RUN deno install RUN deno task build @@ -16,10 +12,6 @@ COPY --from=build /app/src/import_map.json . ENV ORIGIN=http://localhost:3000 -# Set memory limits for runtime to prevent memory leaks -ENV DENO_MEMORY_LIMIT=512MB -ENV DENO_GC_INTERVAL=1000 - RUN deno cache --import-map=import_map.json ./build/index.js EXPOSE 3000 From 1380c3c66b9111ee6c8387138cac6545fc5d8a27 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Thu, 14 Aug 2025 08:53:36 -0500 Subject: [PATCH 3/3] 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(); }