earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
637 stars 20 forks source link

Use Web Locks API for ingestion #291

Open sgwilym opened 1 year ago

sgwilym commented 1 year ago

What's the problem you want solved?

If a replica for a single replica is opened from many processes (e.g. many tabs acting on the same IndexedDB), there's nothing to stop them from attempting concurrent ingestions to the replica. This could lead to invalid or conflicting data on the replica.

There is a local lock on the ingestion process, but this only works within the same process.

Is there a solution you'd like to recommend?

Use the Web Locks API to create locks shared between processes. This API is already supported in all browsers, Deno support isn't far off.

This is pretty critical for the Earthstar Desktop project.