peerbit icon indicating copy to clipboard operation
peerbit copied to clipboard

OPFS persistance with multiple tabs, prevent lock issues

Open marcus-pousette opened this issue 1 year ago • 2 comments
trafficstars

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 avatar Aug 03 '24 09:08 marcus-pousette

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.

marcus-pousette avatar Aug 03 '24 10:08 marcus-pousette

Is this still an issue if Peerbit itself is run in a shared worker?

Erudition avatar Dec 05 '24 01:12 Erudition