Hydrate session PDF byte stores on engine mount.
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Create PdfByteStore with sessionId (IndexedDB) and re-render after hydrate
so the viewer gets live blob URLs after reload.
This commit is contained in:
tegwick 2026-07-30 20:05:25 +02:00
parent 664d7da100
commit a69e5d7881
2 changed files with 19 additions and 1 deletions

View file

@ -153,6 +153,23 @@ export function EngineProvider({
return attachPersister(engine, { key: snapshotKey });
}, [engine, injected, snapshotKey, activeDocKey]);
// Rehydrate PDF bytes from IndexedDB (session-scoped). Snapshot restore
// only brings back metadata; without this the viewer points at a dead
// blob / fake fixture path and PDF.js reports "Invalid PDF structure".
useEffect(() => {
if (injected) return;
let cancelled = false;
void (async () => {
await byteStore.hydrate();
if (!cancelled) {
setEngineRevision((n) => n + 1);
}
})();
return () => {
cancelled = true;
};
}, [byteStore, injected, sessionId]);
// Persist the active-document pointer alongside the engine snapshot so a
// reload lands the user back where they were.
useEffect(() => {

View file

@ -80,7 +80,8 @@ export function SessionProvider({
(sessionId: SessionId) => {
let store = byteStores.get(sessionId);
if (!store) {
store = createPdfByteStore();
// sessionId enables IndexedDB mirror so PDF bytes survive reloads.
store = createPdfByteStore({ sessionId });
byteStores.set(sessionId, store);
}
return store;