quiesceStoreWorker
quiesceStoreWorker(
worker,opts?):Promise<StoreWorkerQuiesceOutcome>
Defined in: packages/client/src/worker/attach-sync-client.ts:401
Quiesce the SharedWorker HOSTING a store, by path, so its backend connection is released BEFORE a
destroyStoreArtifacts on the same path (ADR-0050). The gap it closes: the board’s workers are
extendedLifetime, so a store’s SharedWorker OUTLIVES the document that spawned it — and the idbfs backend
holds its IndexedDB connection open for the engine’s whole life. So after a reload, an idbfs store’s worker
is still alive and still holding the connection; deleteDatabase blocks and destroyStoreArtifacts fails,
boot after boot, until the browser eventually reaps the worker. OPFS releases its handles when idle, so it
never had this problem — this is the idbfs (SW-direct) fix.
worker is a factory (or instance), exactly like attachSyncClient’s worker — the caller constructs
new SharedWorker(url, { name: storePath }), so the library stays DOM-free. Connecting by that name reaches
the LIVE worker (if any) or spawns a fresh one; either way the sequence is: post the declaration, query
placement, and — for a shared-worker home — send engine-teardown and await its reserved ack, which the
host posts only after closeHost() has stopped the engine and released the backend connection (it then
closes its own scope). An elected-worker home resolves immediately with toreDown: false (see the field).
Idempotent and safe on an already-dead store: a fresh spawn boots no engine, and its teardown closes an empty
host. Compose it as await quiesceStoreWorker(f).catch(() => {}); await destroyStoreArtifacts(path) — a
quiesce failure (timeout) must NOT abort the destroy, whose own ownership-lag handling reports honestly and
leaves the path re-runnable.
Parameters
Section titled “Parameters”worker
Section titled “worker”WorkerLike | (() => WorkerLike)
Returns
Section titled “Returns”Promise<StoreWorkerQuiesceOutcome>