8000 feat: add transport compression by davfsa · Pull Request #476 · disgoorg/disgo · GitHub
[go: up one dir, main page]

Skip to content

feat: add transport compression - #476

Merged
topi314 merged 22 commits into
disgoorg:masterfrom
davfsa:feat/transport-compression
Oct 7, 2025
Merged

topi314 merged 22 commits into
disgoorg:masterfrom
davfsa:feat/transport-compression

Conversation

@davfsa
@davfsa davfsa commented Sep 20, 2025
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: davfsa <davfsa@gmail.com>
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway.go Resolved
@davfsa
davfsa force-pushed the feat/transport-compression branch from 40f8e48 to ab27fe5 Compare September 21, 2025 14:01
@Qreepex
Qreepex commented Sep 21, 2025
Copy link
Copy Markdown
Contributor

very nice very nice

@topi314 topi314 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally looks good, just a few things I'd change

Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
@davfsa
davfsa requested a review from topi314 September 22, 2025 08:36
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
8000 Comment thread gateway/gateway_transports.go Resolved
@davfsa
davfsa marked this pull request as draft September 22, 2025 21:47
@davfsa
davfsa marked this pull request as ready for review September 23, 2025 07:12
Signed-off-by: davfsa <davfsa@gmail.com>
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_transports.go Resolved
Comment thread gateway/gateway_config.go Resolved
@davfsa
davfsa requested a review from topi314 October 7, 2025 19:45
@topi314
topi314 merged commit ce5d2b8 into disgoorg:master Oct 7, 2025
@topi314
topi314 commented Oct 7, 2025
Copy link
Copy Markdown
Member

thanks!

sentinelb51 added a commit to sentinelb51/disgo that referenced this pull request Oct 16, 2026
…nnecting

Since the transports were added (disgoorg#476), parseMessage returns every decode
error from ReceiveMessage, and listen handles it as a dead connection:
"failed to read next message", close with 1012, reconnect and resume. The
transport interface says a frame that fails to parse yields a nil Message,
and listen has the matching "No message (probably parsing error), just
continue" branch, which nothing reaches any more. Before disgoorg#476 such a frame
was logged and skipped.

Decode errors of the data are ordinary: Discord adds channel, component,
interaction and integration types, which discord's unmarshalers reject
("unknown channel with type 17 received"). The sequence of the rejected
dispatch was never stored, so the resume replays it, it fails again, and
the session loops through reconnects for as long as Discord replays it; a
GUILD_CREATE with a new channel type keeps a bot from ever settling.

A decode error of the message data is now a messageDataError, and
parseMessage skips that frame (logged, nil Message, no error). The frame
was read whole before its data was decoded, so the decoder and a zlib or
zstd stream are where the next frame starts. Errors reading the frame
itself (I/O, decompression, malformed JSON) still close and reconnect, as
a stream may be out of step after those.

Proof: TestGatewaySkipsUndecodableData (fake gateway sends a CHANNEL_CREATE
of type 999, then a TEST_EVENT with seq 3, uncompressed, zlib-stream and
zstd-stream) sees the client reconnect for all three before, and seq 3
arrive on the same connection after:
  go test -race -count 3 -run TestGatewaySkipsUndecodableData ./gateway
go test -run Decode ./gateway passes unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VRMfn49UbzGanZA9mpsR8F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants

0