Skip to content
New issue

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

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

Already on GitHub? # to your account

Remove blob of zlib data from state machine errors #583

Merged
merged 1 commit into from
May 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/nostrum/shard/session.ex
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,27 @@ defmodule Nostrum.Shard.Session do
{:next_state, :disconnected, %{data | conn: nil, stream: nil}, connect}
end

# :gen_statem callback helper that removes the huge zlib data blob from any
# errors experienced by the shard session state machine. This zlib blob is
# only decodable by the zlib context that the error ocurred in anyway so it's
# inclusion in bug reports only hinders. It has also already been decoded by
# the time it reaches this call so we cannot attempt to decode it here.
def format_status(%{queue: queue} = state) do
queue =
Enum.map(queue, fn queue_item ->
case queue_item do
# match gun websocket messages and remove the data blob
{:info, {:gun_ws, conn, stream, {:binary, _payload}}} ->
{:info, {:gun_ws, conn, stream, {:binary, "PAYLOAD REMOVED"}}}

_ ->
queue_item
end
end)

%{state | queue: queue}
end

# Internal helper. Wait for consumers to start up.
defp wait_for_consumer_boot(reference, timeout) do
receive do
Expand Down