feat(web): replace sql.js with sqlite-wasm and OPFS#52
Conversation
Persist web databases via the official SQLite Wasm OPFS VFS instead of loading the full DB into RAM and mirroring it through IndexedDB. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
📝 WalkthroughWalkthroughChangesThe web database implementation was migrated from sql.js with IndexedDB persistence to SQLite Wasm workers with OPFS persistence and fallback behavior. Public configuration, bundling, Vite headers, architecture documentation, usage guidance, and troubleshooting instructions were updated. SQLite Wasm Web Migration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant App
participant CapgoCapacitorFastSqlWeb
participant sqlite3Worker1Promiser
participant OPFS
App->>CapgoCapacitorFastSqlWeb: connect(databaseName)
CapgoCapacitorFastSqlWeb->>sqlite3Worker1Promiser: open database with OPFS preference
sqlite3Worker1Promiser->>OPFS: access persistent storage
OPFS-->>sqlite3Worker1Promiser: provide storage or report unavailable
sqlite3Worker1Promiser-->>CapgoCapacitorFastSqlWeb: return dbId
App->>CapgoCapacitorFastSqlWeb: execute SQL
CapgoCapacitorFastSqlWeb->>sqlite3Worker1Promiser: exec with object rows
sqlite3Worker1Promiser-->>CapgoCapacitorFastSqlWeb: return rows and metadata
CapgoCapacitorFastSqlWeb-->>App: return query result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
Beta npm buildMaintainers can publish this PR to npm for fast testing. Comment The workflow will:
Security note: beta publish is only enabled for branches inside this repository. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Stale comment
Risk: medium. This PR replaces the web SQL backend (sql.js → sqlite-wasm/OPFS), exceeding the low-risk approval threshold. Cursor Bugbot was not present; CI passed with no unresolved automated findings. Human review is needed; reviewers assigned.
Sent by Cursor Approval Agent: Pull Request Approver External
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
rollup.config.mjs (1)
8-22: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftBundle
@sqlite.org/sqlite-wasmfor the IIFE build
@sqlite.org/sqlite-wasmdoesn’t expose a browser global, soglobals: { '@sqlite.org/sqlite-wasm': 'sqlite3Wasm' }makesdist/plugin.jsfail when loaded directly. Either inline this dependency for the IIFE target or drop the script-tag distribution.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rollup.config.mjs` around lines 8 - 22, Update the IIFE output configuration in rollup.config.mjs to bundle `@sqlite.org/sqlite-wasm` instead of mapping it to the nonexistent sqlite3Wasm browser global; keep the dependency external for the CJS output if required by its existing distribution contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 163-166: Update the README header code fence containing the
Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy lines to include the
text language identifier after the opening fence, preserving the header examples
unchanged.
- Line 648: Update the worker option type in src/definitions.ts to expose Worker
| (() => Worker) instead of any, then regenerate the README API section so its
worker row reflects that type; do not edit README.md directly.
In `@src/web.ts`:
- Around line 137-166: Update the exec request in the method containing this
promiser call to include countChanges: true and lastInsertRowId: true,
preserving the existing SQL execution flow. Adjust the catch block to prefer
error?.result?.message, then error.message, and finally String(error) when
constructing the SQL execution failure.
---
Outside diff comments:
In `@rollup.config.mjs`:
- Around line 8-22: Update the IIFE output configuration in rollup.config.mjs to
bundle `@sqlite.org/sqlite-wasm` instead of mapping it to the nonexistent
sqlite3Wasm browser global; keep the dependency external for the CJS output if
required by its existing distribution contract.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d1079ca1-153c-4c23-913a-c3084bf00fa6
⛔ Files ignored due to path filters (1)
bun.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
ARCHITECTURE.mdREADME.mdSETUP.mdexample-app/vite.config.tspackage.jsonrollup.config.mjssrc/definitions.tssrc/performance-config.tssrc/web.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
Cap-go/capacitor-updater(manual)
💤 Files with no reviewable changes (1)
- src/performance-config.ts
Pass countChanges/lastInsertRowId on exec, unwrap Worker1 errors, bundle sqlite-wasm into the IIFE build, and tighten WebConfig docs. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>


Summary
@sqlite.org/sqlite-wasmand OPFS persistence (fixes feat: replace sql.js with sqlite-wasm and OPFS #51)WebConfig/ docs for COOP/COEP requirements; example Vite config sets isolation headersTest plan
bun run build/bun run verify:webpassMade with Cursor
Summary by CodeRabbit
New Features
Documentation
Bug Fixes