Skip to content

provisionSyncWorker

provisionSyncWorker<TRegistry>(options): Promise<void>

Defined in: packages/client/src/worker/attach-sync-client.ts:2580

Pre-spawn a worker’s store WITHOUT attaching (ADR-0032 decision 5). Sent at the board’s login screen against a freshly-named spare SharedWorker: the worker runs PGlite create/initdb only and holds the raw store idle until the real attachSyncClient claim adopts it. Resolves when the worker acks the provision (its initdb settled); rejects if the worker reports the create failed, if it refuses the storage declaration, if the elected engine is unconstructible, or — bounding the whole thing — with ProvisionExpiredError once provisionExpiryMs (default 60000) elapses without any of those. The caller treats every outcome as best-effort: a provision that fails or expires costs the accelerator, not the boot — the attach that follows meets whatever the worker actually opened (an expiry bounds THIS promise; the worker-side create attempt is kept or retired by the placement — see ProvisionExpiredError).

Routed through the SAME placement-query-first flow as attachSyncClient (ADR-0049 step 8): a SW-direct (or declared-idbfs) SharedWorker takes the provision bridge envelope on the SW port; a router-only (electionRequired) SharedWorker DROPS bridge envelopes, so provision drives the election coordinator’s PROVISION CLAIM (expiry-bounded) and delivers the provision over the elected engine’s per-tab PIPE. The coordinator is REGISTERED per store so a later attach on the same tab ADOPTS the grant — no second lock, no second engine, no double initdb (invariant 2). Elected mode REQUIRES a createEngineWorker factory (mirroring attach); its absence is a clear rejection, never a hang.

TRegistry extends SyncTableRegistry

ProvisionSyncWorkerOptions<TRegistry>

Promise<void>