Skip to content

refactor(wa-sqlite): initialize the extension after opening - #210

Merged
Antonov548 merged 1 commit into
mainfrom
refactor/wa-sqlite-explicit-init
Jul 17, 2026
Merged

refactor(wa-sqlite): initialize the extension after opening#210
Antonov548 merged 1 commit into
mainfrom
refactor/wa-sqlite-explicit-init

Conversation

@marcus-pousette

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

Copy link
Copy Markdown
Collaborator

Problem

TreeCRDT ran as a SQLite automatic extension, so OPFS file opening and asynchronous schema initialization shared one sqlite3_open_v2 retry budget. With wa-sqlite 1.1.1, both phases can pause for VFS work and exhaust that shared budget during startup.

Change

  • Keep TreeCRDT statically linked, but initialize it explicitly after SQLite opens.
  • Give schema initialization its own retry boundary, draining only concrete pending VFS work.
  • Use the same open-then-initialize sequence in browser, worker, Node, and benchmark paths.
  • Close database and VFS resources if explicit initialization fails.
  • Pin wa-sqlite 1.1.1 / SQLite 3.53 at fork master commit 5bae8bd.

This isolates TreeCRDT initialization from sqlite3_open_v2. Generic failed-open handle cleanup is tracked separately in wa-sqlite #330 and does not block this fix.

Merge order

Merge this with a merge commit, then retarget #208 to main.

@marcus-pousette marcus-pousette added maintenance Refactor, tests, CI, release, or dependency work without intended behavior change area:sqlite SQLite extension, sqlite-node, wa-sqlite persistence, and migrations area:web Browser, WASM, OPFS, workers, and playground runtime labels Jul 12, 2026
@marcus-pousette
marcus-pousette force-pushed the refactor/wa-sqlite-explicit-init branch from c625b2c to ad5fa21 Compare July 12, 2026 16:05
@marcus-pousette
marcus-pousette force-pushed the stack/wa-sqlite-shared-worker-lifecycle branch from ea62da3 to dc51f82 Compare July 13, 2026 14:31
@marcus-pousette
marcus-pousette force-pushed the refactor/wa-sqlite-explicit-init branch from ad5fa21 to dd6635c Compare July 13, 2026 14:31
@marcus-pousette
marcus-pousette force-pushed the stack/wa-sqlite-shared-worker-lifecycle branch from dc51f82 to 16ca00c Compare July 14, 2026 20:43
@marcus-pousette
marcus-pousette force-pushed the refactor/wa-sqlite-explicit-init branch 2 times, most recently from 4ef9ef6 to 7d9878c Compare July 15, 2026 06:45
@marcus-pousette
marcus-pousette force-pushed the stack/wa-sqlite-shared-worker-lifecycle branch from 16ca00c to fe1ffde Compare July 15, 2026 06:45
@marcus-pousette
marcus-pousette changed the base branch from stack/wa-sqlite-shared-worker-lifecycle to main July 15, 2026 07:16
@marcus-pousette
marcus-pousette force-pushed the refactor/wa-sqlite-explicit-init branch from 7d9878c to c3b9927 Compare July 15, 2026 07:16
@marcus-pousette
marcus-pousette force-pushed the refactor/wa-sqlite-explicit-init branch 2 times, most recently from 4401d00 to 1952830 Compare July 16, 2026 09:52
@marcus-pousette
marcus-pousette force-pushed the refactor/wa-sqlite-explicit-init branch from 1952830 to 0a2f290 Compare July 16, 2026 11:30
@Antonov548
Antonov548 merged commit 21b19ae into main Jul 17, 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 maintenance Refactor, tests, CI, release, or dependency work without intended behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants