Fix out of order path WS broadcasts overwriting each other

This commit is contained in:
Jack Kingsman
2026-02-16 18:30:27 -08:00
parent 8457799a60
commit 1f853aa54e
2 changed files with 9 additions and 3 deletions
+5 -3
View File
@@ -70,11 +70,13 @@ export function updateAck(messageId: number, ackCount: number, paths?: MessagePa
for (const entry of cache.values()) {
const idx = entry.messages.findIndex((m) => m.id === messageId);
if (idx >= 0) {
const current = entry.messages[idx];
const updated = [...entry.messages];
updated[idx] = {
...entry.messages[idx],
acked: ackCount,
...(paths !== undefined && { paths }),
...current,
acked: Math.max(current.acked, ackCount),
...(paths !== undefined &&
paths.length >= (current.paths?.length ?? 0) && { paths }),
};
entry.messages = updated;
return; // Message IDs are unique, stop after first match