From 215d24eb0ea1aefc06790cf7e5d92ec437967f6a Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Mon, 5 Jan 2026 20:44:06 -0800 Subject: [PATCH] fix: use connection.socket for @fastify/websocket v8 --- backend/src/plugins/websocket.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/websocket.ts b/backend/src/plugins/websocket.ts index ed89102..8a13ebb 100644 --- a/backend/src/plugins/websocket.ts +++ b/backend/src/plugins/websocket.ts @@ -13,7 +13,7 @@ interface AlertMessage { timestamp: string; } -// Connected clients (using any to avoid ws type issues) +// Connected clients (storing the raw WebSocket) const clients: Map = new Map(); export async function websocketPlugin(fastify: FastifyInstance) { @@ -22,9 +22,12 @@ export async function websocketPlugin(fastify: FastifyInstance) { /** * WebSocket endpoint for real-time alerts */ - fastify.get('/ws/alerts', { websocket: true }, (socket, request) => { + fastify.get('/ws/alerts', { websocket: true }, (connection, request) => { const clientId = `${Date.now()}-${Math.random().toString(36).slice(2)}`; + // Get the raw WebSocket from the SocketStream + const socket = connection.socket; + clients.set(clientId, socket); fastify.log.info(`WebSocket client connected: ${clientId}`);