Skip to content

ZlibStreamDecoder

Defined in: packages/ws/src/decoder.ts:65

Decodes Discord’s zlib-stream transport compression.

Discord sends one zlib stream whose logical payloads are separated by the Z_SYNC_FLUSH marker 00 00 FF FF. A payload may span several WebSocket messages, so output is produced only when that marker arrives: a partial payload is retained rather than guessed at.

The inflater carries state across frames, so push calls must not interleave. WebSocketTransport serialises them by construction.

new ZlibStreamDecoder(create?, maxFrameBytes?): ZlibStreamDecoder

Defined in: packages/ws/src/decoder.ts:88

() => Inflate

Inflater factory; injected in tests.

number = ...

Largest inflated frame accepted (default 64 MiB); past it the stream fails instead of growing until memory runs out.

ZlibStreamDecoder

push(data): string[] | Promise<string[]>

Defined in: packages/ws/src/decoder.ts:103

A text frame on a compressed connection is already a complete frame, so it is returned synchronously and never touches the inflater. Discord sends everything binary under zlib-stream; tolerating a string costs nothing, and treating one as a decode failure — or delaying it by a microtask — would both change observable behaviour.

unknown

string[] | Promise<string[]>

GatewayDecoder.push


reset(): void

Defined in: packages/ws/src/decoder.ts:144

Discards buffered state. Call when a connection is replaced.

void

GatewayDecoder.reset