Runs fn while no client worker holds the persistent client's storage.
Rewriting OPFS from outside the client — importing a profile, say — needs the pool's sync access
handles released, and neither client.destroy() nor a page reload proves that: the handles belong
to the dedicated worker, which the browser tears down asynchronously after the document goes away.
A write that beats it fails with NoModificationAllowedError. The worker holds
STORAGE_LOCK_KEY for its whole life and releases it only once its SQLite connection is
closed (and the platform releases it if the worker is killed outright), so taking that lock is the
one reliable proof that the storage is free.
Runs
fnwhile no client worker holds the persistent client's storage.Rewriting OPFS from outside the client — importing a profile, say — needs the pool's sync access handles released, and neither
client.destroy()nor a page reload proves that: the handles belong to the dedicated worker, which the browser tears down asynchronously after the document goes away. A write that beats it fails withNoModificationAllowedError. The worker holds STORAGE_LOCK_KEY for its whole life and releases it only once its SQLite connection is closed (and the platform releases it if the worker is killed outright), so taking that lock is the one reliable proof that the storage is free.