v0.59.0: SSE frames drop terminal package history (sseFrame projection) — ~597 KB → ~10 KB per frame (#133)
CI / build + unit + e2e (pull_request) Successful in 17m7s

This commit is contained in:
2026-09-23 05:49:17 +00:00
parent c5413aff65
commit 6a819b8d5a
7 changed files with 105 additions and 11 deletions
+7 -5
View File
@@ -1,9 +1,11 @@
import { getStateSnapshot } from '@/lib/game/state';
import { getStateSnapshot, sseFrame } from '@/lib/game/state';
import { subscribe } from '@/lib/sse';
// ISS-129 (v0.57.0): Server-Sent Events feed of full state snapshots — the current snapshot on
// connect, then one after every sim tick (broadcast from lib/sim/engine.ts). One-way push; player
// actions stay REST POSTs. Heartbeats keep idle proxies from dropping the connection.
// ISS-129 (v0.57.0): Server-Sent Events feed of state snapshots — the current snapshot on connect,
// then one after every sim tick (broadcast from lib/sim/engine.ts). One-way push; player actions
// stay REST POSTs. Heartbeats keep idle proxies from dropping the connection. ISS-133 (v0.59.0):
// frames carry the sseFrame projection (terminal package history dropped) — same shape as the
// pushed frames, so a connect never costs one full-history frame.
const encoder = new TextEncoder();
const HEARTBEAT_MS = 15_000;
@@ -39,7 +41,7 @@ export async function GET() {
// same as above
}
}, HEARTBEAT_MS);
controller.enqueue(encoder.encode(`data: ${JSON.stringify(snapshot)}\n\n`));
controller.enqueue(encoder.encode(`data: ${JSON.stringify(sseFrame(snapshot))}\n\n`));
})
.catch(() => {
cleanup();