Skip to content

Commit 5d38f05

Browse files
committed
fix(discord): raise gateway payload cap for large events
1 parent 25bd7ac commit 5d38f05

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

extensions/discord/src/internal/gateway-websocket-options.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("GatewayPlugin websocket options", () => {
3838
expect(webSocketCtorCalls).toHaveLength(1);
3939
expect(webSocketCtorCalls[0]).toEqual({
4040
url: "wss://gateway.example.test/?v=10&encoding=json",
41-
options: { maxPayload: 1024 * 1024 },
41+
options: { maxPayload: 16 * 1024 * 1024 },
4242
});
4343
});
4444
});

extensions/discord/src/internal/gateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type GatewayPluginOptions = {
4848
const READY_STATE_OPEN = 1;
4949
const DEFAULT_GATEWAY_URL = "wss://gateway.discord.gg/";
5050
const DISCORD_GATEWAY_PAYLOAD_LIMIT_BYTES = 4096;
51-
export const DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES = 1024 * 1024;
51+
export const DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES = 16 * 1024 * 1024;
5252
const INVALID_SESSION_MIN_DELAY_MS = 1_000;
5353
const INVALID_SESSION_JITTER_MS = 4_000;
5454

extensions/discord/src/monitor/gateway-plugin.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const { GatewayIntents, GatewayPlugin } = vi.hoisted(() => {
5454
});
5555

5656
vi.mock("../internal/gateway.js", () => ({
57-
DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES: 1024 * 1024,
57+
DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES: 16 * 1024 * 1024,
5858
GatewayIntents,
5959
GatewayPlugin,
6060
}));

extensions/discord/src/monitor/provider.proxy.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ const {
146146

147147
// Unit test: don't import the real gateway just to check the prototype chain.
148148
vi.mock("../internal/gateway.js", () => ({
149-
DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES: 1024 * 1024,
149+
DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES: 16 * 1024 * 1024,
150150
GatewayIntents,
151151
GatewayPlugin,
152152
}));
153153

154154
vi.mock("../internal/gateway.js", () => ({
155-
DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES: 1024 * 1024,
155+
DISCORD_GATEWAY_WS_MAX_PAYLOAD_BYTES: 16 * 1024 * 1024,
156156
GatewayIntents,
157157
GatewayPlugin,
158158
}));
@@ -400,7 +400,7 @@ describe("createDiscordGatewayPlugin", () => {
400400
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
401401
agent: getLastAgent(),
402402
handshakeTimeout: 30_000,
403-
maxPayload: 1024 * 1024,
403+
maxPayload: 16 * 1024 * 1024,
404404
});
405405
expect(wsProxyAgentSpy).not.toHaveBeenCalled();
406406
});
@@ -518,7 +518,7 @@ describe("createDiscordGatewayPlugin", () => {
518518
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
519519
agent: getLastProxyAgent(),
520520
handshakeTimeout: 30_000,
521-
maxPayload: 1024 * 1024,
521+
maxPayload: 16 * 1024 * 1024,
522522
});
523523
expect(runtime.log).toHaveBeenCalledWith("discord: gateway proxy enabled");
524524
expect(runtime.error).not.toHaveBeenCalled();
@@ -541,7 +541,7 @@ describe("createDiscordGatewayPlugin", () => {
541541
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
542542
agent: getLastProxyAgent(),
543543
handshakeTimeout: 30_000,
544-
maxPayload: 1024 * 1024,
544+
maxPayload: 16 * 1024 * 1024,
545545
});
546546
expect(runtime.log).toHaveBeenCalledWith("discord: gateway proxy enabled");
547547
expect(runtime.error).not.toHaveBeenCalled();
@@ -564,7 +564,7 @@ describe("createDiscordGatewayPlugin", () => {
564564
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
565565
agent: getLastProxyAgent(),
566566
handshakeTimeout: 30_000,
567-
maxPayload: 1024 * 1024,
567+
maxPayload: 16 * 1024 * 1024,
568568
});
569569
expect(runtime.error).not.toHaveBeenCalled();
570570
expect(runtime.log).toHaveBeenCalledWith("discord: gateway proxy enabled");
@@ -586,7 +586,7 @@ describe("createDiscordGatewayPlugin", () => {
586586
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
587587
agent: getLastAgent(),
588588
handshakeTimeout: 30_000,
589-
maxPayload: 1024 * 1024,
589+
maxPayload: 16 * 1024 * 1024,
590590
});
591591
expect(runtime.log).not.toHaveBeenCalled();
592592
});
@@ -607,7 +607,7 @@ describe("createDiscordGatewayPlugin", () => {
607607
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
608608
agent: getLastProxyAgent(),
609609
handshakeTimeout: 30_000,
610-
maxPayload: 1024 * 1024,
610+
maxPayload: 16 * 1024 * 1024,
611611
});
612612
expect(runtime.log).toHaveBeenCalledTimes(1);
613613
expect(runtime.log).toHaveBeenCalledWith("discord: gateway proxy enabled");
@@ -699,7 +699,7 @@ describe("createDiscordGatewayPlugin", () => {
699699
expect(webSocketSpy).toHaveBeenCalledWith("wss://gateway.discord.gg", {
700700
agent: getLastProxyAgent(),
701701
handshakeTimeout: 30_000,
702-
maxPayload: 1024 * 1024,
702+
maxPayload: 16 * 1024 * 1024,
703703
});
704704
expect(runtime.error).not.toHaveBeenCalled();
705705
expect(runtime.log).toHaveBeenCalledWith("discord: gateway proxy enabled");

0 commit comments

Comments
 (0)