Closed proof-llc closed 10 months ago
it occurs at this line: const { sql } = new SQLocal('database.sqlite3');
creating a file in OPFS manually works properly:
const opfsRoot = await navigator.storage.getDirectory();
const fileHandle = await opfsRoot.getFileHandle('database.sqlite3', { create: true });
weird.. everything works fine if i create the file with the code above first - then your lib has no problem updating it. but it doesn't want to create the file on its own. For now I am unblocked, but I'll keep the issue open so we can figure out the root of the issue.
That's not an issue I've run into. The file should be created automatically on the first write. What browser are you using? Is anything else in your app interacting with the OPFS?
i tried in latest Chrome, Chrome Beta and Safari. Same results. Nothing else is interacting with OPFS.
Hmmm. What operating system? Shouldn't matter but just in case there's some difference with how the browser implements storage between OS's.
Would you be able to make a minimal reproduction of the issue so we can see what's happening?
macOS 14.1. Here's a new repo with the code: https://github.com/proof-llc/sqlocal-demo
code doesn't work until we uncomment here: https://github.com/proof-llc/sqlocal-demo/blob/main/src/routes/%2Bpage.svelte#L10
Thanks for the reproduction. I found the issue. It was caused by a mistake I made in a change for 0.6.2. I've just released the fix in 0.6.3.
Awesome, thanks!
The browser throws the error below. Any ideas?
sqlite3-opfs-async-proxy.js?type=classic&worker_file:90 OPFS asyncer: xOpen DOMException: A requested file or directory could not be found at the time an operation was processed. logImpl @ sqlite3-opfs-async-proxy.js?type=classic&worker_file:90 error @ sqlite3-opfs-async-proxy.js?type=classic&worker_file:94 xOpen @ sqlite3-opfs-async-proxy.js?type=classic&worker_file:645 await in xOpen (async) f @ sqlite3-opfs-async-proxy.js?type=classic&worker_file:951 await in f (async) globalThis.onmessage @ sqlite3-opfs-async-proxy.js?type=classic&worker_file:990 Show 5 more frames Show less sqlite3-bundler-friendly.mjs?v=6b26e52b:12388 OPFS syncer: xOpen() async error: NotFoundError: A requested file or directory could not be found at the time an operation was processed. logImpl @ sqlite3-bundler-friendly.mjs?v=6b26e52b:12388 error @ sqlite3-bundler-friendly.mjs?v=6b26e52b:12392 opRun @ sqlite3-bundler-friendly.mjs?v=6b26e52b:12614 f @ sqlite3-bundler-friendly.mjs?v=6b26e52b:12958 $func507 @ sqlite3.wasm:0x24d5f $func501 @ sqlite3.wasm:0x240d9 $sqlite3_open_v2 @ sqlite3.wasm:0x251ea (anonymous) @ sqlite3-bundler-friendly.mjs?v=6b26e52b:7747 ctor @ sqlite3-bundler-friendly.mjs?v=6b26e52b:10589 OpfsDb @ sqlite3-bundler-friendly.mjs?v=6b26e52b:13174 value @ processor.js?v=6b26e52b:56 await in value (async) value @ processor.js?v=6b26e52b:125 value @ processor.js?v=6b26e52b:91 self.onmessage @ worker.js?type=module&worker_file:4 Show 14 more frames Show less client.js?v=6b26e52b:56 Uncaught SQLite3Error: SQLITE_IOERR: sqlite3 result code 10: disk I/O error at toss3 (sqlite3-bundler-friendly.mjs?v=6b26e52b:10492:17) at checkSqlite3Rc (sqlite3-bundler-friendly.mjs?v=6b26e52b:10511:13) at OpfsDb.ctor (sqlite3-bundler-friendly.mjs?v=6b26e52b:10591:13) at new OpfsDb (sqlite3-bundler-friendly.mjs?v=6b26e52b:13174:45) at SQLocalProcessor.value [as init] (processor.js?v=6b26e52b:56:35) value @ client.js?v=6b26e52b:56 Show 1 more frame Show less