Skip to content

fix(wa-sqlite): allow long OPFS database paths - #213

Merged
Antonov548 merged 1 commit into
mainfrom
fix/wa-sqlite-opfs-path-capacity
Jul 13, 2026
Merged

fix(wa-sqlite): allow long OPFS database paths#213
Antonov548 merged 1 commit into
mainfrom
fix/wa-sqlite-opfs-path-capacity

Conversation

@marcus-pousette

@marcus-pousette marcus-pousette commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator

What

Allow valid OPFS database paths longer than wa-sqlite's 64-byte VFS default.

TreeCRDT now advertises a 512-byte pathname capacity before registering either OPFS VFS:

  • CoopSync in dedicated workers.
  • AnyContext in direct/main-thread mode.

Why

SQLite appends sidecar names such as -journal and -wal after checking the VFS pathname capacity. A 58-byte database path therefore becomes a 66-byte journal path and fails with the generic SQLITE_CANTOPEN / sqlite3_open_v2 error when the VFS reports 64 bytes.

This was reproduced exactly in Chromium:

  • 54-byte database path, 62 with -journal: opens.
  • 58-byte database path, 66 with -journal: fails with the old limit.
  • The same 58-byte path opens when the VFS advertises 512 bytes.

The failure looked like an OPFS drop/reopen race in #164 only because its normal-priority filename was four characters shorter than its background-priority filename.

Scope / fast paths

Regression coverage

The existing browser lifecycle matrix now deliberately uses a database path whose -journal form exceeds 64 bytes. It covers both direct/AnyContext and dedicated-worker/CoopSync clients, explicit close and reload teardown, persistence, and drop cleanup.

Verification

  • wa-sqlite TypeScript build passes.
  • Prettier and git diff --check pass.
  • Playwright covers all four long-path lifecycle scenarios.
  • Full GitHub build, browser, native-node, playground, and Postgres CI is green.

@marcus-pousette marcus-pousette added bug Something isn't working area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations area:web Browser, WASM, OPFS, workers, and playground runtime labels Jul 12, 2026
@Antonov548
Antonov548 merged commit cd6e1b9 into main Jul 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations area:web Browser, WASM, OPFS, workers, and playground runtime bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants