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

Improve the error message when trying to use OPFS outside of a worker #201

Open
TheAndrewJackson opened this issue Aug 14, 2024 · 3 comments

Comments

@TheAndrewJackson
Copy link

Description

I'm running into an issue when trying to create a new database using the OPFS AHP file system. This snippet

import { PGlite } from "@electric-sql/pglite";

const client = await PGlite.create({
  dataDir: "opfs-ahp://electric.db",
  relaxedDurability: true,
});

is producing this error

image

I have a minimal-repro repo here that has the issue: https://github.com/TheAndrewJackson/opfs-ahp_bug_repro

@AntonOfTheWoods
Copy link
Contributor

https://pglite.dev/examples/opfs

It needs to be somewhere that allows the sync api, so in a web/service (shared?) worker.

@samwillis
Copy link
Collaborator

Thanks for the report @TheAndrewJackson

The OPFS AHP VFS only works in a dedicated web worker as it requires the sync access handle API which is not available on the main thread, in shared workers, or in service workers.

We should improve the error message on this.

@samwillis samwillis changed the title Issue with creating database using the OPFS AHP file system Improve the error message when trying to use OPFS outside of a worker Aug 15, 2024
@TheAndrewJackson
Copy link
Author

ahh, that makes sense @samwillis. Thanks for the clarification!

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

3 participants