TinyBase logoTinyBase β

getFragmentSize

The getFragmentSize method is used to specify a target maximum UTF-8 byte size for each WebSocket message fragment sent by the Durable Object. Unicode code points are never split and can exceed this size. TinyBase sends at most 1,000 fragments for one payload, increasing the target when needed.

getFragmentSize(): undefined | number
returnsundefined | number

The target maximum fragment size, or undefined to disable fragmentation.

Return a number to split larger synchronization payloads into fragments that are reassembled by the receiving WsSynchronizer. Return undefined to send each payload as a single WebSocket message.

Example

This example limits outbound Durable Object synchronization message fragments to 32KB.

import {WsServerDurableObject} from 'tinybase/synchronizers/synchronizer-ws-server-durable-object';

export class MyDurableObject extends WsServerDurableObject {
  getFragmentSize() {
    return 32 * 1024;
  }
}

Since

v9.0.0