Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load db file from Wasm/StackBlitz #286

Open
buzzb0x opened this issue Nov 12, 2024 · 0 comments
Open

Unable to load db file from Wasm/StackBlitz #286

buzzb0x opened this issue Nov 12, 2024 · 0 comments

Comments

@buzzb0x
Copy link

buzzb0x commented Nov 12, 2024

Hello,

I'm trying to create a full-stack project that will both contain the DB itself and the front-end with a back-office and a client-facing web-app. I thought trying to use libsql for this would be appropriate.

I tried to get started using StackBlitz's Bolt platform to generate a Next.js project but quickly ran into this error:

Module not found: Can't resolve './'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@libsql/client/node_modules/@libsql/libsql-wasm-experimental/node.mjs
./node_modules/@libsql/client/lib-esm/wasm.js
./lib/db.ts
./app/page.tsx

In db.ts I create a file database using @libsql/client and in app/page.tsx I call the db to retrieve resources to render. Here is a light reproduction → from the Next.js starter on StackBlitz.

I tried to fix it by using an in-memory db or importing from @libsql/client-wasm to no avail. Then, I started from scratch, saw that this libsql demo on StackBlitz → is working and tried to build from there.

What I can't understand is where the db file is stored? Trying to initialize the client with a local file works outside of Wasm but on StackBlitz it always fails with this error: (StackBlitz →)

Error: SQLITE_CANTOPEN: sqlite3 result code 14: unable to open database file
    at async ModuleLoader.import (https://nodezjhahv-rpb4.w-credentialless-staticblitz.com/builtins.ddb8d84d.js:154:2688)
    at async loadESM (https://nodezjhahv-rpb4.w-credentialless-staticblitz.com/builtins.ddb8d84d.js:184:541)
    at async handleMainPromise (https://nodezjhahv-rpb4.w-credentialless-staticblitz.com/builtins.ddb8d84d.js:165:296) {
  resultCode: 14,
  name: 'SQLite3Error'
}

I feel like these are two intertwined issues as they involve the way the package works with Wasm environments.

Possibly related issues:

  • #159 StackBlitz support?
  • I also saw another still open issue that said the Wasm code wasn't bundled yet but can't find it again, and it does seem to be bundled.

Environment

  • @libsql/client: 0.14.0 (@libsql/client-wasm)
  • next: 13.5.1
  • node: v18.20.3

Thanks in advance for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant