discordjs/discord.js · info

WebSocketShard: transport compression is enabled, disabling

Error message

WebSocketShard: transport compression is enabled, disabling identify compression

What it means

This is a warning (console.warn) emitted by WebSocketShard.internalConnect when both a transport compression option (e.g. 'zlib-stream' / 'zstd-stream') and useIdentifyCompression are enabled. The Discord gateway does not allow identify payload (zlib-stream framed) compression to be combined with transport-level compression, so the shard disables identify compression and keeps transport compression. Nothing fails; the shard simply adjusts the URL 'compress' query parameter and clears this.identifyCompressionEnabled.

Source

Thrown at packages/ws/src/ws/WebSocketShard.ts:192

			// cleanup hanging listeners
			controller.abort();
		}

		this.initialConnectResolved = true;
	}

	private async internalConnect() {
		if (this.#status !== WebSocketShardStatus.Idle) {
			throw new Error("Tried to connect a shard that wasn't idle");
		}

		const { version, encoding, compression, useIdentifyCompression } = this.strategy.options;
		this.identifyCompressionEnabled = useIdentifyCompression;

		const params = new URLSearchParams({ v: version, encoding });
		if (compression !== null) {
			if (useIdentifyCompression) {
				console.warn('WebSocketShard: transport compression is enabled, disabling identify compression');
				this.identifyCompressionEnabled = false;
			}

			params.append('compress', CompressionParameterMap[compression]);

			switch (compression) {
				case CompressionMethod.ZlibNative: {
					const zlib = await getNativeZlib();
					if (zlib) {
						this.inflateBuffer = [];

						const inflate = zlib.createInflate({
							chunkSize: 65_535,
							flush: zlib.constants.Z_SYNC_FLUSH,
						});

						inflate.on('data', (chunk) => {
							this.inflateBuffer.push(chunk);

View on GitHub (pinned to a81ed8a306)

Solutions

  1. Remove useIdentifyCompression: true from options if you want transport compression (this is the intended setup).
  2. Set compression: null if identify compression is what you actually want.
  3. Ignore the warning; it is informational and the shard automatically disables identify compression.
  4. Suppress console.warn noise only if you understand the trade-off; do not wrap in code that changes behavior.

Example fix

// before
const manager = new WebSocketManager({
  compression: CompressionMethod.ZlibStream,
  useIdentifyCompression: true,
});
// after
const manager = new WebSocketManager({
  compression: CompressionMethod.ZlibStream,
});
Defensive patterns

Strategy: validation

Validate before calling

const transportCompression = options.compression != null;
const identifyCompression = options.useIdentifyCompression === true;
if (transportCompression && identifyCompression) {
  console.warn('transport compression and useIdentifyCompression are mutually exclusive; identify compression will be disabled');
}

Prevention

When it happens

Trigger: Passing a WebSocketShardOptions.compression value that is not null while also setting useIdentifyCompression: true when connecting a shard (via WebSocketManager options or direct WebSocketShard.connect).

Common situations: Developers enabling every compression option 'to be safe' in discord.js options; copy-pasted config from examples that set both zlib-stream transport compression and identify compression; upgrading code where an older manager defaulted identify compression on and transport compression was later added.

Related errors


AI-assisted analysis of discordjs/discord.js@a81ed8a306 (2026-08-30). Data as JSON: /api/errors/f5f9cfb09172f764. Report an issue: GitHub.