dao-xyz / peerbit

P2P database framework with encryption, sharding and search
https://peerbit.org
Apache License 2.0
193 stars 15 forks source link

OPFS persistance with multiple tabs, prevent lock issues #304

Open marcus-pousette opened 3 months ago

marcus-pousette commented 3 months ago

Current solution for persistance in the browser is to use OPFS for block and indexing store. This works well when only one tab is used, but when multiple tabs want to access the same file we will run into problems because accessHandles can only be accessed by one tab at once.

marcus-pousette commented 3 months ago

Possible solution.

Make one tab "parent" and the other ones "children".

When parent tab closed down, make one of the children the parent. All requests from the parent are done directly to the OPFS worker, while the other will broadcast a request to the other parent.