Improve messaging and dashboard reliability

This commit is contained in:
jjbrunton committed 2026-08-08 21:09:20 +01:00
1 parent 345ec99348
commit 5a5a30a1d4
20 files changed
+406 -56

No files matched your search

+9 -1
View File
@@ -197,6 +197,14 @@ export function createExpressSseHandler(
}
try {
// A first-time subscriber repairs authoritative dashboard snapshots on
// open and only needs events published from this point onwards. Replaying
// the entire buffer here can overflow the bounded response queue and
// force EventSource into a reconnect loop. A genuine reconnect supplies
// Last-Event-ID and still receives every buffered event after its cursor.
const requestedLastEventId = request.get('Last-Event-ID');
const replayCursor = requestedLastEventId
?? options.hub.recent(1).at(-1)?.id;
subscription = options.hub.subscribe(
(event) => {
if (!active) {
@@ -208,7 +216,7 @@ export function createExpressSseHandler(
close(true);
}
},
{ lastEventId: request.get('Last-Event-ID') },
{ lastEventId: replayCursor },
);
} catch {
close(true);