Skip to content

Conversation

@valzargaming
Copy link
Member

@valzargaming valzargaming commented Nov 21, 2025

https://discord.com/developers/docs/events/gateway#zstdstream
https://github.com/kjdev/php-ext-zstd
https://phpext.phptools.online/extension/zstd-334

This pull request adds support for Zstandard (zstd) compression in addition to the existing zlib compression for WebSocket payloads in the Discord client. If the ext-zstd extension is available, the client will now prefer zstd-stream compression, falling back to zlib-stream if not. The changes include dependency updates, new decompression logic, and improved logging for compression handling.

Compression support improvements:

  • Added ext-zstd as a suggested dependency in composer.json for Zstandard compression support.
  • Updated the Discord client to initialize and use a Zstd decompression context (ZstdContext) if the extension is available, falling back to zlib decompression otherwise. [1] [2] [3]

WebSocket message handling:

  • Modified the WebSocket message handler to decompress binary payloads using Zstd if available, or zlib otherwise, and added error logging for failed decompression attempts.

Logging and diagnostics:

  • Added debug logging to indicate which compression method (zstd-stream or zlib-stream) is being used during connection parameter setup.

@valzargaming valzargaming linked an issue Nov 21, 2025 that may be closed by this pull request
@valzargaming valzargaming requested a review from a team November 21, 2025 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zstd-stream compression support

2 participants