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

Fix invalid storage in webworker #67

Merged
merged 1 commit into from
Apr 2, 2024
Merged

Conversation

JfrAziz
Copy link
Contributor

@JfrAziz JfrAziz commented Apr 1, 2024

I found bug when using storage in web worker, it always fallback to nodefs no matter what storage we use. turns out, when we initialize PGLiteWorker, we parse dataDir

const { dataDir: dir, fsType } = parseDataDir(dataDir);
this.dataDir = dir;

now dataDir is the parsed value, for example from idb://my-database to only /my-database without idb://. then when we initialize the worker, we are using parsed value instead the the raw value, and this value will be parsed again in PGLite

async #init() {
    await this.#worker.init(this.dataDir, { debug: this.debug });
    this.#ready = true;
}

so no mattter what storage used in web worker, it's always using nodefs, because we always parsing the parsed value to PGLite

Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great spot, thanks!

@samwillis samwillis merged commit a889520 into electric-sql:main Apr 2, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants