Skip to content

fix(store): heal a database that version 1 left empty - #11

Merged
frahlg merged 1 commit into
mainfrom
repair-broken-db
Aug 5, 2026
Merged

fix(store): heal a database that version 1 left empty#11
frahlg merged 1 commit into
mainfrom
repair-broken-db

Conversation

@frahlg

@frahlg frahlg commented Aug 5, 2026

Copy link
Copy Markdown
Member

Follow-up to #9, which stopped the launch probe from creating an empty database — but could not help an install that already had one. Version 2 with an idempotent upgrade repairs the schema in place; a healthy database is untouched, rows included. Tests build the broken state deliberately and open it the way the app does.

The launch probe could create 'ftw' at version 1 with no object stores, and
an app opening the same version got no upgrade callback and created none
either — every read and write broken for the life of the install. The probe
no longer does that, but prevention cannot reach a phone already in that
state. Only a version it has not seen can.

Version 2, with an upgrade that creates each store only if it is missing. A
broken database gets its schema; a healthy one is untouched, rows and all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 5, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
ftw-webapp 2a7bbf6 Aug 05 2026, 05:43 PM

@frahlg
frahlg merged commit 92b1a54 into main Aug 5, 2026
2 checks passed
@frahlg
frahlg deleted the repair-broken-db branch August 5, 2026 17:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a7bbf6f8c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/store/db.ts
// either, so every read and write failed for the life of the install. The
// probe no longer does that — but installs that already suffered it cannot be
// healed by prevention, only by a version they have not seen.
const DB_VERSION = 2

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the boot probe before forcing the v2 upgrade

When an existing v1 install launches with ftw.site set, the inline boot probe still opens indexedDB.open('ftw', 1) and, on success, never closes req.result after checking/reading snapshot (index.html:74 and index.html:93-99). Bumping the app open to version 2 makes that still-open v1 connection block the upgrade that is supposed to repair the database, so the exact broken v1 installs this targets can leave db() pending for the session; after a successful v2 upgrade, the same v1 probe will also just VersionError and skip the first-frame cached snapshot path. Please update the probe to the new version and close or onversionchange-close its connection as part of this bump.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant