From efce3ebe7be89c2846c74edd2b8cee39f9862564 Mon Sep 17 00:00:00 2001 From: Adam Shiervani Date: Wed, 9 Apr 2025 17:00:44 +0200 Subject: [PATCH] Fix/more logging (#34) * A tiny bit clearer logging * Enhance WebSocket close event logging to include closure code and reason --- src/webrtc-signaling.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/webrtc-signaling.ts b/src/webrtc-signaling.ts index d126a2c..ad504e1 100644 --- a/src/webrtc-signaling.ts +++ b/src/webrtc-signaling.ts @@ -172,16 +172,18 @@ function setupDeviceWebSocket(deviceWs: WebSocket, device: Device, req: Incoming await cleanup(); }); - deviceWs.on("close", async () => { - console.log(`[Device] Connection closed for ${id}`); + deviceWs.on("close", async (code, reason) => { + console.log( + `[Device] Connection closed for ${id} with code ${code} and reason ${reason}`, + ); await cleanup(); }); // Cleanup function async function cleanup() { + console.log(`[Device] Cleanup for ${id}`); activeConnections.delete(id); clearInterval(checkAliveInterval); - console.log(`[Device] Cleanup for ${id}`); await updateDeviceLastSeen(id); } }