Skip to content

feat: zstd streaming support #10758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

feat: zstd streaming support #10758

wants to merge 2 commits into from

Conversation

vladfrangu
Copy link
Member

Please describe the changes this PR makes and why it should be merged:

Brings in native zstd streaming support for gateway decompression in environments that have it

That said, I'm leaving this as a draft for now, and seeing how zstd support progresses in node (specifically the backporting)

If someone wants to test it locally with their bots that have bigger payloads, you can use a script like this, after cloning this PR and building the repo

import { REST } from '@discordjs/rest';
import { CompressionMethod, WebSocketManager } from '@discordjs/ws';

const token = '';

const rest = new REST({}).setToken(token);

const manager = new WebSocketManager({
	intents: 0,
	rest,
	token,
	shardCount: 16,
	shardIds: [0],
	helloTimeout: 10_000,
	compression: CompressionMethod.ZstdNative,
});

manager.on('debug', console.log);
manager.on('error', console.error);

await manager.connect();
console.log('Connected');

Runnable with volta run --node 23 node script.mjs or whichever tool floats your boat.

Ideally we'd have some non native zstd module too but there doesn't seem to be any that exist right now 🙃

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Copy link

vercel bot commented Feb 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 8:26pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Feb 14, 2025 8:26pm

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 6.45161% with 29 lines in your changes missing coverage. Please review.

Project coverage is 38.62%. Comparing base (4b63bb8) to head (d9ce818).
Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
packages/ws/src/ws/WebSocketShard.ts 0.00% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10758      +/-   ##
==========================================
- Coverage   38.67%   38.62%   -0.06%     
==========================================
  Files         239      239              
  Lines       14653    14678      +25     
  Branches     1385     1385              
==========================================
+ Hits         5667     5669       +2     
- Misses       8974     8997      +23     
  Partials       12       12              
Flag Coverage Δ
ws 34.20% <6.45%> (-0.49%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jiralite Jiralite added this to the ws 3.0.0 milestone Feb 14, 2025
@sdanialraza sdanialraza changed the title feat(ws): zstd streaming support feat: zstd streaming support Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

4 participants