Skip to content

fix: let a newer tab upgrade the library instead of waiting silently - #54

Merged
bencode merged 1 commit into
mainfrom
fix/db-upgrade-blocked
Oct 1, 2026
Merged

bencode merged 1 commit into
mainfrom
fix/db-upgrade-blocked

Conversation

@bencode

@bencode bencode commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Why

When the library's IndexedDB version goes up (it just did, 6 → 7), any tab still holding the old version blocks the upgrade. The new page then sits on "Loading files…" forever, with no hint why. This happened during testing of #52, with an old page open in another browser.

What changes

  • data/workspace-database.ts
    • blocking: when a newer page wants to upgrade, this tab closes its connection so the upgrade can finish.
    • Deletions (blockedVersion === null) are deliberately not given way to. Project deletion already waits for other tabs to close, and giving way would let this tab recreate the deleted library empty on its next read.
    • blocked: forwarded to an optional onBlocked passed to openWorkspaceDatabase.
  • shell/project-root.tsx: the library is opened during boot, before the workbench mounts.
    • If the open is blocked, the page shows "Waiting for other tabs that have open to close." This reuses the deletion wording.
    • Once the other tab lets go, the page continues by itself.
    • Open failures still surface through the existing error and retry states.

Limits

  • Tabs already running the released version-6 code have no blocking handler, so they still have to be closed by hand this one time. Future upgrades benefit.
  • A tab that gave way is running outdated code. Its next read fails with the existing "could not be opened" error until it is reloaded. A dedicated "reload this page" prompt is left for later.

Tests

  • data/workspace-database.test.ts
    • The library gives way to a higher-version open. Without the fix this test hangs, which I confirmed.
    • The library does not give way to a deletion.
  • shell/projects.integration.test.tsx: a held version-6 connection shows the waiting message. Once it closes, the files appear, migrated.

pnpm check passes. The existing "deletes only what this tab asked for" test is occasionally flaky under full-suite load. That happens on main too, and it passes 8/8 in isolation with and without this change.

A tab holding the library now closes it when a newer page asks to upgrade, and
a page whose upgrade is held up by an older tab says so and carries on by
itself once that tab lets go. Deletions still wait for other tabs to close.
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