Browse Source

Merge branch 'fix-merge' of ssh://onedev.gitcitadel.eu:6611/Alexandria/gc-alexandria into fix-merge

master
silberengel 7 months ago
parent
commit
bf992b7e9e
  1. 10
      Dockerfile
  2. 5
      src/lib/data_structures/websocket_pool.ts

10
Dockerfile

@ -1,11 +1,7 @@ @@ -1,11 +1,7 @@
FROM denoland/deno:alpine AS build
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 . @@ -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

5
src/lib/data_structures/websocket_pool.ts

@ -211,6 +211,7 @@ export class WebSocketPool { @@ -211,6 +211,7 @@ export class WebSocketPool {
}
}
this.#pool.clear();
console.debug('[WebSocketPool] Pool drained successfully');
}
@ -252,6 +253,8 @@ export class WebSocketPool { @@ -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 { @@ -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();
}

Loading…
Cancel
Save