API reference › @evolu/common › local‑first/Protocol › ProtocolMessageMaxSize

const ProtocolMessageMaxSize: between(
  minProtocolMessageMaxSize,
  maxProtocolMessageMaxSize,
)(Int);

Defined in: packages/common/src/local-first/Protocol.ts:344

Protocol message maximum size, from 1MB to 100MB.

A message never exceeds its maximum size, inclusive. Builders measure each write exactly and keep room to close the message (see ProtocolMessageBuffer.tryWrite), and sync sends what does not fit in later rounds.

Clients send at most defaultProtocolMessageMaxSize and enforce no receive limit. A relay can answer with larger messages, configured with the totalMaxSize option of applyProtocolMessageAsRelay, to reduce roundtrips for large syncs. Clients must not send larger messages, because relays accept at most the default: the Node.js relay closes the connection on a larger one, and relays up to @evolu/nodejs 4.0.0 crash on it.

The default cannot be smaller either. Deployed clients send messages of that size, a change within maxMutationSize fits one message next to the largest ranges section, and changes saved before that limit existed, which can be nearly as large as a message, must stay servable.