fix: repair IDB schema lost after browser crash (closes #28) - #32
Draft
kasunben wants to merge 3 commits into
Draft
fix: repair IDB schema lost after browser crash (closes #28)#32kasunben wants to merge 3 commits into
kasunben wants to merge 3 commits into
Conversation
Bumped IndexedDB version from 1 to 2 so `onupgradeneeded` re-runs for any v1 database that lost its object stores after a browser crash mid-upgrade (manifested as "IDBDatabase.transaction: 'threads' is not a known object store name" → fallback to memory-only mode, annotations lost on refresh). `db.onversionchange` now only calls `db.close()` — no forced `window.location.reload()`, which was causing a reload cascade during Playwright page navigations and was the root cause of the E2E reload test flake on this branch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
kasunben
force-pushed
the
fix/idb-schema-missing
branch
from
June 8, 2026 22:58
4112c21 to
6c05e51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openDBfrom version 1 to version 2 soonupgradeneededre-runs for any v1 database that lost its object stores after a browser crash mid-upgradecreateObjectStorecall with!objectStoreNames.contains(...)so the upgrade is fully idempotent — existing intact databases are unaffectedwindow.location.reload()from thedb.onversionchangehandler;db.close()alone is sufficient to unblock future upgrades, and the forced reload was causing a reload cascade during Playwright navigations (root cause of the E2E reload-persistence test flake on this branch)Root cause
On some browsers (notably Firefox), a crash during the very first
onupgradeneededexecution leaves the IndexedDB at version 1 with no object stores. On every subsequent page load,openDB(siteId, 1)sees the DB already at v1 and skipsonupgradeneeded. The firstdb.transaction('threads', 'readonly')call then throws:The entire init promise chain falls into
.catch, logging:In server-sync mode this is especially destructive —
pullThreads,flushDirtyThreads, andsetIntervalare never wired up, so annotations appear to vanish on every page refresh.Test plan
npm run test:all— 82 unit + integration tests pass; 15 E2E tests pass (1 skipped: P2P relay, requires deployed relay)onversionchangereload removal; now passesdemo-sync-with-server.html, annotate, refresh — annotations persistannotate-default(leaving the DB at v1 with no stores), then reload — annotations should work normally (stores recreated by v2 upgrade)🤖 Generated with Claude Code