diff --git a/public/index.html b/public/index.html
index 3801202..94cb33e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1428,6 +1428,13 @@
const reader = res.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
+ // Persist eventType across reader chunks. SSE events are
+ // `event: X\ndata: Y\n\n`, but a single TCP/fetch chunk can split
+ // between those two lines — when that happens, we'd lose the event
+ // type and silently drop the event (e.g. the final `result` for a
+ // long video, where the payload is tens of KB). Reset only after
+ // dispatch, per the SSE spec.
+ let eventType = "";
while (true) {
const { done, value } = await reader.read();
@@ -1437,13 +1444,13 @@
const lines = buffer.split("\n");
buffer = lines.pop() || "";
- let eventType = "";
for (const line of lines) {
if (line.startsWith("event: ")) {
eventType = line.slice(7);
} else if (line.startsWith("data: ")) {
const data = JSON.parse(line.slice(6));
handleSSE(eventType, data);
+ eventType = "";
}
}
}