From 5d535d18d8df29c4ad83bb5999569ff6f551e027 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sun, 13 Sep 2026 23:07:51 +0200 Subject: [PATCH] Switch to Socket.IO; fix two real memory leaks Requested: Socket.IO instead of raw WebSockets, and explicit attention to memory leaks. Auditing for the second turned up two real, concrete leaks, independent of the transport library: 1. Server-side: a raw `ws` server has no idea a client is gone unless it gets a proper close frame - a sleeping laptop, a network drop, a killed tab never fire 'close', so the PartyMember's socket reference (and everything it closes over) sat in memory forever, and the party was never cleaned up by anything else either (removeIdleParties only looks at lastActivityUtc). Socket.IO's built-in heartbeat (pingInterval/pingTimeout) detects and closes these out on its own - a real, not just cosmetic, reason to prefer it here. 2. Client-side: router.js only ever did currentRoot.innerHTML = '' between routes, destroying DOM but never telling the outgoing view's JS to stop. Leaving the player any way other than its own "Quitter" button (a sidebar link, browser back) left the 3s heartbeat setInterval, the realtime connection, and the hls.js instance all running against a detached