Skip to content

PgwasmProtocol

Defined in: packages/pgwasm/src/core/internals.ts:31

What protocol(pg) returns.

readonly capabilities: BuildCapabilities

Defined in: packages/pgwasm/src/core/internals.ts:56

The build’s capabilities, e.g. to check synchronousExchange before relying on it.

execProtocol(message, options?): Promise<ExecProtocolResult>

Defined in: packages/pgwasm/src/core/internals.ts:33

Run frontend message bytes; the parsed backend messages and the raw reply.

Uint8Array

ExecProtocolOptions

Promise<ExecProtocolResult>


execProtocolRaw(message, options?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: packages/pgwasm/src/core/internals.ts:37

Run frontend message bytes; the raw reply. Notifications and errors are still dispatched.

Uint8Array

Pick<ExecProtocolOptions, "persist">

Promise<Uint8Array<ArrayBufferLike>>


execProtocolRawStream(message, options): Promise<void>

Defined in: packages/pgwasm/src/core/internals.ts:43

Run frontend message bytes and stream the raw reply. When nothing is pending and the build has synchronousExchange, the whole reply is delivered before this call returns its promise — what a tool driving it from inside a blocking wasm callback (pg_dump) needs.

Uint8Array

ExecProtocolStreamOptions

Promise<void>


execProtocolStream(message, options?): Promise<BackendMessage[]>

Defined in: packages/pgwasm/src/core/internals.ts:35

Run frontend message bytes; the parsed backend messages only.

Uint8Array

ExecProtocolOptions

Promise<BackendMessage[]>


runExclusiveSession<T>(fn): Promise<T>

Defined in: packages/pgwasm/src/core/internals.ts:54

Run fn with the database’s session to itself, for a tool whose exchanges must not interleave with anything else (pg_dump). It waits for, then holds, the locks a transaction() holds, and the query lock: no query, exec, transaction, listen, live-query refresh or Store backup of this database runs until fn settles.

What fn sends with the execProtocol* methods is its own responsibility: no transaction is begun or ended around it, and a message is persisted only as its options say. Inside fn, use only these wire methods: the database’s query methods wait for the locks fn holds, so awaiting one deadlocks.

T

() => Promise<T>

Promise<T>