DallasHoff / sqlocal

SQLocal makes it easy to run SQLite3 in the browser, backed by the origin private file system.
https://sqlocal.dallashoffman.com
MIT License
322 stars 15 forks source link

sqlite3 result code 10: disk I/O error #8

Closed proof-llc closed 10 months ago

proof-llc commented 11 months ago

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

proof-llc commented 11 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 });
proof-llc commented 11 months ago

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.

DallasHoff commented 11 months ago

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?

proof-llc commented 11 months ago

i tried in latest Chrome, Chrome Beta and Safari. Same results. Nothing else is interacting with OPFS.

DallasHoff commented 11 months ago

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?

proof-llc commented 10 months ago

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

DallasHoff commented 10 months ago

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.

proof-llc commented 10 months ago

Awesome, thanks!