Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

"Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state" ?#286

Unanswered
chanon asked this question inQ&A
Discussion options

Hello, I am using wa-sqlite instead of the official SQLite wasm because I like the wa-sqlite interface better.

But I'm running into an issue in Safari that looks like it is the same thing as:
sqlite/sqlite-wasm#79 (comment)

But I'm getting it as an unhandled exception.

I'm not completely sure if it is the same thing. This is how I am initializing (in a Worker):

import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';import { AccessHandlePoolVFS as VFS } from 'wa-sqlite/src/examples/AccessHandlePoolVFS.js';import * as SQLite from 'wa-sqlite';// Initialize SQLite and handle messagesasync function initializeSQLite() {try {const module = await SQLiteESMFactory();sqlite3 = SQLite.Factory(module);// register vfs system.const vfs = new VFS('dbs')// @ts-ignoresqlite3.vfs_register(vfs, true);}catch (error: any) {console.error(error)ctx.postMessage('failed')}}

I get the error as an unhandled rejection:

let retries = 0addEventListener('unhandledrejection', async (ev) => {console.error('worker unhandledrejection!:')console.log(ev)retries++;if (retries > 5)returnawait initializeSQLite()})

Doing the above doesn't fix it, but just creates more
Unhandled Promise Rejection: InvalidStateError: The object is in an invalid state
rejections.

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

My guess would be that you have multiple contexts accessing the same OPFS files, e.g. you have multiple tabs open on your page or one page is opening multiple Workers. AccessHandlePoolVFS works only on one context at a time.

Apart from that you haven't provided enough information for me to debug it (such as the wa-sqlite version, a stack trace, whether it works on other browsers, etc.) without investing a lot of effort. I suggest creating a test web page with aminimal reproducible example that shows the bad behavior, e.g. using GitHub Pages.

Alternatively, you can look at how thedemo handles initialization indemo-worker.js, or the much simplerhello demo (you'll need to change its VFS), and see where what you're doing diverges.

You must be logged in to vote
1 reply
@chanon
Comment options

Thank you for the response.
I am specifically managing multiple tabs by using a Worker and leader tab election.
The problem happens in Safari sometimes when reloading a single tab,
If I keep having the problem I will try creating a minimal reproduction as you say.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@chanon@rhashimoto

[8]ページ先頭

©2009-2025 Movatter.jp