Interface: SyncHandlerOptions<S, TCtx>
このコンテンツはまだ日本語訳がありません。
Interface: SyncHandlerOptions<S, TCtx>
Section titled “Interface: SyncHandlerOptions<S, TCtx>”Defined in: server/src/sync-handler.ts:116
Type Parameters
Section titled “Type Parameters”S extends Schema<Record<string, AnyTable>>
TCtx
Properties
Section titled “Properties”schema
Section titled “schema”
readonlyschema:S
Defined in: server/src/sync-handler.ts:117
executor
Section titled “executor”
readonlyexecutor:SqlExecutor
Defined in: server/src/sync-handler.ts:118
dialect?
Section titled “dialect?”
readonlyoptionaldialect?:SqlDialect
Defined in: server/src/sync-handler.ts:119
schemaVersion
Section titled “schemaVersion”
readonlyschemaVersion:string
Defined in: server/src/sync-handler.ts:120
mutators
Section titled “mutators”
readonlymutators:Record<string,Mutator<S,TCtx,any>>
Defined in: server/src/sync-handler.ts:122
readonlyauth: (request) =>Promise<AuthResult<TCtx>>
Defined in: server/src/sync-handler.ts:123
Parameters
Section titled “Parameters”request
Section titled “request”Request
Returns
Section titled “Returns”Promise<AuthResult<TCtx>>
basePath?
Section titled “basePath?”
readonlyoptionalbasePath?:string
Defined in: server/src/sync-handler.ts:125
Path prefix; defaults to /sync.
onPushed?
Section titled “onPushed?”
readonlyoptionalonPushed?: (auth) =>void|Promise<void>
Defined in: server/src/sync-handler.ts:133
Called once per successful push (i.e. after every mutation batch that
changed something). Use it to nudge subscribed clients to pull now —
the canonical wiring is a Durable Object SyncCoordinator broadcasting
over WebSocket. Kept optional; the client’s poll interval is a working
fallback when this is absent.
Parameters
Section titled “Parameters”clientGroupID
Section titled “clientGroupID”string
clientID
Section titled “clientID”string
TCtx
Returns
Section titled “Returns”void | Promise<void>
onError?
Section titled “onError?”
readonlyoptionalonError?: (event) =>void
Defined in: server/src/sync-handler.ts:144
Observability sink. Called with a discriminated SyncServerError any
time the handler swallows or rejects a request — so failed mutations,
schema mismatches, and onPushed failures land in your logs / Sentry
even though the wire response is friendly.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
maxMutationsPerPush?
Section titled “maxMutationsPerPush?”
readonlyoptionalmaxMutationsPerPush?:number
Defined in: server/src/sync-handler.ts:151
Maximum number of mutations accepted in a single push request. A push exceeding this is rejected with 413 before any mutator runs — a defence against a compromised or buggy client trying to burn D1 write budget. Default: 200.
maxPayloadBytes?
Section titled “maxPayloadBytes?”
readonlyoptionalmaxPayloadBytes?:number
Defined in: server/src/sync-handler.ts:158
Maximum body size accepted for push. Requests larger are rejected
with 413 before JSON parsing. Default: 1 MiB. Applied via the
Content-Length header when present — clients that omit it are
allowed through and the mutation cap catches the rest.
envelopeValidation?
Section titled “envelopeValidation?”
readonlyoptionalenvelopeValidation?: {maxCiphertextBytes?:number;allowedKeyIds?: readonlystring[];maxKemCiphertextBytes?:number; }
Defined in: server/src/sync-handler.ts:165
Server-side encryption envelope validator. Called for any value that
looks like a plasma Envelope ({ v, alg, keyId, nonce, ct }) in
incoming mutation args, so a compromised client can’t push oversized
ciphertexts or unknown key ids. Absent → basic shape check only.
maxCiphertextBytes?
Section titled “maxCiphertextBytes?”
readonlyoptionalmaxCiphertextBytes?:number
allowedKeyIds?
Section titled “allowedKeyIds?”
readonlyoptionalallowedKeyIds?: readonlystring[]
maxKemCiphertextBytes?
Section titled “maxKemCiphertextBytes?”
readonlyoptionalmaxKemCiphertextBytes?:number
Cap the kem.ct field of a PQ hybrid envelope (base64 length,
pre-decode). ML-KEM-768 ciphertexts are 1088 bytes ≈ 1452 chars
base64; the default 4096 leaves headroom for larger PQ
primitives without letting a malicious client inflate the KEM
ciphertext up to the per-mutation cap. v1.0 zeus W3 fix.
blobs?
Section titled “blobs?”
readonlyoptionalblobs?: {default:Storage; }
Defined in: server/src/sync-handler.ts:183
Storage adapter map for file() columns. v0.3 only honours a single
default entry; per-table override lands in v0.4 (createSyncHandler
throws at startup when a non-default storageRef is seen — see spec
§Q9 / plan §C2). Required when the schema declares any file() column.
default
Section titled “default”
readonlydefault:Storage
readAuthMaxRefs?
Section titled “readAuthMaxRefs?”
readonlyoptionalreadAuthMaxRefs?:number
Defined in: server/src/sync-handler.ts:193
Reverse-lookup fan-out cap for blob GET auth. assertCanReadBlob
only inspects the newest N refs pointing at a hash; if none of them
belong to a row the caller can read, the request is denied even
when an older ref would have. This is a performance guard for
viral content-addressed assets (see round-4 W-1). Defaults to 128 —
bump if you have shared assets referenced by many rows and want
exhaustive auth to always find a readable owner.
waitUntil?
Section titled “waitUntil?”
readonlyoptionalwaitUntil?: (promise) =>void
Defined in: server/src/sync-handler.ts:199
Non-blocking Cache API put hook. Typically ctx.waitUntil.bind(ctx)
from the fetch handler. When absent the cache write awaits inline;
that is safe but stretches p95 for cold-cache blob GETs.
Parameters
Section titled “Parameters”promise
Section titled “promise”Promise<unknown>
Returns
Section titled “Returns”void