Skip to content

Commit 99f5ac9

Browse files
authored
fix(wasm): override logger functions (#3024)
1 parent 3e8d6d8 commit 99f5ac9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/runtime/internal/database.client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export function loadDatabaseAdapter<T>(collection: T): DatabaseAdapter {
3636
async function loadAdapter<T>(collection: T) {
3737
if (!db) {
3838
const sqlite3InitModule = await import('@sqlite.org/sqlite-wasm').then(m => m.default)
39+
// @ts-expect-error sqlite3ApiConfig is not defined in the module
40+
globalThis.sqlite3ApiConfig = {
41+
// overriding default log function allows to avoid error when logger are dropped in build.
42+
// For example `nuxt-security` module drops logger in production build by default.
43+
silent: true,
44+
debug: (...args: unknown[]) => console.debug(...args),
45+
warn: (...args: unknown[]) => console.warn(...args),
46+
error: (...args: unknown[]) => console.error(...args),
47+
log: (...args: unknown[]) => console.log(...args),
48+
}
3949
const sqlite3 = await sqlite3InitModule()
4050
db = new sqlite3.oo1.DB()
4151
}

0 commit comments

Comments
 (0)