Skip to content

byobug/worker-query-data

Repository files navigation

kysely-wasqlite-worker queryData close reproduction

Minimal SvelteKit reproduction for a suspected prepared statement leak in kysely-wasqlite-worker@1.2.1.

The page runs normal Kysely execute() queries through WaSqliteWorkerDialect, then immediately calls db.destroy(). The dialect is configured with preferOPFS: true and otherwise uses the package defaults.

Run

pnpm install
pnpm dev

Open the local Vite URL, open the browser console, and click Run reproduction.

Or run the browser reproduction directly:

pnpm test

Expected

db.destroy() should close the SQLite worker cleanly.

Actual

In the failing case, db.destroy() rejects with:

unable to close due to unfinalized statements or unfinished backups

The browser console also logs each reproduction step with the [worker-query-data-repro] prefix.

Relevant upstream code

queryData manually calls next() on the sqlite.statements(...) async iterator:

https://github.com/subframe7536/kysely-sqlite-tools/blob/master/packages/dialect-wasqlite-worker/src/worker/utils.ts#L37-L68

@subframe7536/sqlite-wasm documents that manual iterator users should call return() if iteration is abandoned before completion:

https://github.com/subframe7536/sqlite-wasm/blob/master/src/types/api.ts#L529-L566

About

kysely-wasqlite-worker appears to leave a prepared statement open in the normal `queryData` path

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors