From 5932dc7e779bb98a9e7e21a1d51f8f2268c0e573 Mon Sep 17 00:00:00 2001 From: PJ Date: Sun, 26 Apr 2026 22:19:29 +0700 Subject: [PATCH] refactor(folio-webApp): hard-fail when OPFS unavailable Drops the silent in-memory fallback. The README claims OPFS persistence; falling back without surfacing the degrade made data loss invisible across reloads. Now the worker errors out and the Kotlin DriverFactory rejects the create() call instead. --- .../src/wasmJsMain/resources/sqlite.worker.js | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/examples/folio/app/webApp/src/wasmJsMain/resources/sqlite.worker.js b/examples/folio/app/webApp/src/wasmJsMain/resources/sqlite.worker.js index c189003..0fc0c69 100644 --- a/examples/folio/app/webApp/src/wasmJsMain/resources/sqlite.worker.js +++ b/examples/folio/app/webApp/src/wasmJsMain/resources/sqlite.worker.js @@ -1,7 +1,6 @@ import sqlite3InitModule from '@sqlite.org/sqlite-wasm'; let db = null; -let isPersistent = false; async function init() { const sqlite3 = await sqlite3InitModule({ @@ -9,20 +8,13 @@ async function init() { printErr: (msg) => console.error('[sqlite]', msg), }); - try { - const pool = await sqlite3.installOpfsSAHPoolVfs({ - directory: '/folio-sqlite-pool', - clearOnInit: false, - initialCapacity: 6, - }); - db = new pool.OpfsSAHPoolDb('/folio.sqlite3'); - isPersistent = true; - console.log('[sqlite] using OPFS SAH pool'); - } catch (sahErr) { - console.warn('[sqlite] OPFS SAH pool unavailable, falling back to in-memory:', sahErr?.message ?? sahErr); - db = new sqlite3.oo1.DB(':memory:', 'ct'); - isPersistent = false; - } + const pool = await sqlite3.installOpfsSAHPoolVfs({ + directory: '/folio-sqlite-pool', + clearOnInit: false, + initialCapacity: 6, + }); + db = new pool.OpfsSAHPoolDb('/folio.sqlite3'); + console.log('[sqlite] using OPFS SAH pool'); } function execQuery(sql, params) {