Fixed redis issues
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user