Skip to content

Commit

Permalink
fix: Improve handling of realtime_channel.ex on transaction error (#1236
Browse files Browse the repository at this point in the history
)
  • Loading branch information
filipecabaco authored Nov 27, 2024
1 parent 8aef8f8 commit 5deb4f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/realtime_web/channels/realtime_channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,13 @@ defmodule RealtimeWeb.RealtimeChannel do
end

@impl true
def handle_info(:postgres_subscribe, socket) do
def handle_info(:postgres_subscribe, %{assigns: %{channel_name: channel_name}} = socket) do
%{
assigns: %{
tenant: tenant,
pg_sub_ref: pg_sub_ref,
pg_change_params: pg_change_params,
postgres_extension: postgres_extension,
channel_name: channel_name,
postgres_cdc_module: module
}
} = socket
Expand Down Expand Up @@ -286,6 +285,11 @@ defmodule RealtimeWeb.RealtimeChannel do
push_system_message("postgres_changes", socket, "error", error, channel_name)
{:noreply, assign(socket, :pg_sub_ref, postgres_subscribe(5, 10))}
end
rescue
error ->
log_error("UnableToSubscribeToPostgres", error)
push_system_message("postgres_changes", socket, "error", error, channel_name)
{:noreply, assign(socket, :pg_sub_ref, postgres_subscribe(5, 10))}
end

@impl true
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.33.59",
version: "2.33.60",
elixir: "~> 1.17.3",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit 5deb4f3

Please sign in to comment.