fix: stabilize color mapping by using persistent global hash and add SSE heartbeat
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m18s

This commit is contained in:
Cauê Faleiros
2026-05-07 14:08:38 -03:00
parent d3167dbac1
commit 3bb46cff1a
2 changed files with 19 additions and 2 deletions

View File

@@ -74,9 +74,15 @@ app.get('/api/stream', (req, res) => {
// Send initial connection event
res.write('data: {"connected": true}\n\n');
// Keep connection alive through Nginx/Cloudflare
const keepAlive = setInterval(() => {
res.write(':\n\n'); // SSE comment to prevent idle timeout
}, 15000);
sseClients.add(res);
req.on('close', () => {
clearInterval(keepAlive);
sseClients.delete(res);
});
});