Skip to content

Commit

Permalink
fix: catch errors from decode_payload (#231)
Browse files Browse the repository at this point in the history
* fix: catch errors from decode_payload
  • Loading branch information
abc3 authored Dec 20, 2023
1 parent 22b584b commit afd2a5c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.8
1.0.9
3 changes: 3 additions & 0 deletions lib/supavisor/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,9 @@ defmodule Supavisor.ClientHandler do

send(pool_proc, {:handle_ps, payload, bin})
end)
else
error ->
Logger.debug("Skip prepared statement #{inspect(error)}")
end
end

Expand Down
13 changes: 9 additions & 4 deletions lib/supavisor/protocol/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ defmodule Supavisor.Protocol.Client do
{:error, {:undefined_tag, <<char>>}}

tag ->
payload_len = pkt_len - 4
<<bin_payload::binary-size(payload_len), _::binary>> = rest

{:ok, decode_payload(tag, bin_payload)}
try do
payload_len = pkt_len - 4
<<bin_payload::binary-size(payload_len), _::binary>> = rest

{:ok, decode_payload(tag, bin_payload)}
rescue
reason ->
{:error, {:decode_payload_error, reason}}
end
end
end

Expand Down

0 comments on commit afd2a5c

Please sign in to comment.