Skip to content

Commit

Permalink
Merge pull request #583 from Kraigie/jb3/statem-cleaner-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 authored May 5, 2024
2 parents febaaa1 + 10988e0 commit f7d1139
Showing 1 changed file with 21 additions and 0 deletions.
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

0 comments on commit f7d1139

Please # to comment.