From d5db0d1352e530e52fe9269da7e3c57fb5a23b1f Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sun, 15 Feb 2026 00:21:56 +0100 Subject: [PATCH] Fixed redis issues --- src/app/api/view-run/route.ts | 4 ++-- src/modules/live-run/core.ts | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/api/view-run/route.ts b/src/app/api/view-run/route.ts index 3bc6c7c..bb8c58c 100644 --- a/src/app/api/view-run/route.ts +++ b/src/app/api/view-run/route.ts @@ -12,7 +12,7 @@ export function GET(req: NextRequest) { } export function UPGRADE(client: WebSocket, server: WebSocketServer) { - const subscriber = new Redis(); + const subscriber = new Redis(process.env.REDIS_URL!); let runId: string; client.once("message", async (message) => { @@ -59,7 +59,7 @@ export function UPGRADE(client: WebSocket, server: WebSocketServer) { }); client.once("close", async () => { - if (runId) await subscriber.unsubscribe(`liveRun:${runId}`); + await subscriber.unsubscribe(`liveRunEvent:${runId}`); subscriber.quit(); await updateLiveRunViews(runId, -1); }); diff --git a/src/modules/live-run/core.ts b/src/modules/live-run/core.ts index 6d90c0a..305b9b9 100644 --- a/src/modules/live-run/core.ts +++ b/src/modules/live-run/core.ts @@ -79,8 +79,6 @@ export async function addLiveRunEvent( language: string, moves: LiveRunMove[], ) { - const redis = new Redis(); - // Make sure the live run exists const runExists = await redis.exists(`liveRun:${runId}`); if (!runExists) throw "Invalid live run";