push updated state to clients over SSE (ISS-129)
CI / build + unit + e2e (pull_request) Successful in 11m7s

This commit is contained in:
2026-09-22 20:44:13 +00:00
parent 9b2938a5b0
commit 1983d17099
13 changed files with 354 additions and 21 deletions
+6 -4
View File
@@ -211,12 +211,14 @@ export async function persist(instance: GameDb): Promise<void> {
await fs.rename(tmp, instance.file);
}
// Singleton for the app process; openGameDb() is the uncached variant (tests).
let ready: Promise<GameDb> | null = null;
// Singleton for the app process; openGameDb() is the uncached variant (tests). ISS-129 (v0.57.0):
// lives on globalThis because Next.js can load this module more than once per process —
// instrumentation.ts and route handlers get separate module instances, so a plain `let` would give
// each its own in-memory sql.js DB (both persisting to the same file). One world per process.
const g = globalThis as unknown as { __flightGameDb?: Promise<GameDb> };
export function getGameDb(): Promise<GameDb> {
if (!ready) ready = open(defaultDbPath());
return ready;
return (g.__flightGameDb ??= open(defaultDbPath()));
}
export async function openGameDb(file: string): Promise<GameDb> {