Data is not persisted when using WaSqliteWorkerDialect
Feroks opened this issue · 3 comments
Feroks commented
I have SvelteKit SPA application and use following code to initialize Kyseley
:
import { Kysely } from 'kysely';
import { WaSqliteWorkerDialect } from 'kysely-wasqlite-worker'
import type { Database } from './types';
const dialect = new WaSqliteWorkerDialect({
fileName: 'test',
preferOPFS: true
});
return new KyselyEx<Database>({ dialect });
If i initialize it again or reload the page all my data and tables are gone. I have tried to set preferOPFS
to false
, but it does not help.
I guess i am doing something wrong. Do you have any suggestions?
subframe7536 commented
- check if your browser support OPFS
- check if the worker and wasm is loaded, you can see examples in playground
- if
preferOPFS: false
, go to devtools > Application > IndexedDB and check if the database exists - if
preferOPFS: true
, use OPFS explorer extension and check if the directory exists
Also, there will be some improvements and bug fix if I have some times to release
Feroks commented
- I am using latest Chrome version (on PC).
- I can see worker in Developer tools. HTTP request that loads WASM is succesfull
isIdbSupported
,isModuleWorkerSupport
andisOpfsSupported
all returntrue
. I can run queries on the database, but the moment page is refreshed, data is gone. - Database exists, but there is no data event after performing insert.
- Directory exists. It has 6 files with random text as name.
subframe7536 commented
You're right. I tested it locally and there indeed is a data loss issue.
You can use v0.5.1 for now. Maybe it is caused by the upstream lib and need some times to fix it