Improve event stream resilience

This commit is contained in:
Bohdan Triapitsyn
2026-04-24 12:30:11 +03:00
parent f0c3d5e326
commit 9d9af7e263
8 changed files with 240 additions and 2 deletions
@@ -209,7 +209,22 @@ export const registerScheduledTaskRoutes = (app, dependencies) => {
} catch {
}
const heartbeat = setInterval(() => {
try {
writeSseEvent(res, {
type: 'openchamber:heartbeat',
properties: {
timestamp: Date.now(),
},
});
} catch {
clearInterval(heartbeat);
clients.delete(res);
}
}, 25_000);
req.on('close', () => {
clearInterval(heartbeat);
clients.delete(res);
});
});