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

pouchdb-browser in SharedWorker #8865

Open
egorovd opened this issue Feb 27, 2024 · 2 comments
Open

pouchdb-browser in SharedWorker #8865

egorovd opened this issue Feb 27, 2024 · 2 comments

Comments

@egorovd
Copy link

egorovd commented Feb 27, 2024

Issue

Error start 'pouchdb-browser' in SharedWorker

Info

  • Environment: browser
  • Platform: Chrome
  • Adapter: indexeddb
  • Server: none

Reproduce

I tried to run the 'pouchdb-browser' in the browser and nothing worked:

pnpm install --save pouchdb-browser
pnpm i --save-dev @types/pouchdb-browser

in SharedWorker

import PouchDB from 'pouchdb-browser'

const = new PouchDB('test')

image
image

Can this be somehow fixed or resolved?
Thank you.

@SourceR85
Copy link
Contributor

pouchdb-browser currently supports main-thread only (need foundational changes to run in a worker scope).

@garethbowen
Copy link
Member

@egorovd There is a community supported package for running in workers: https://github.com/pouchdb-community/worker-pouch . Note that it's very old so may not work, but it's reasonably simple.

I used to use it many years ago and it made the main thread noticeably more responsive (eg: UI), however the big downside was moving all the data between the pouch thread and the main thread. The serialization cost ended up being worse than just doing everything in one thread. It would be good for something that does a lot of db access and number crunching without necessarily returning everything to the UI. Alternatively using SharedArrayBuffer may solve the problem.

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