Skip to content

Commit

Permalink
fix: Properly handle error on handle_continue (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipecabaco authored Oct 19, 2024
1 parent 66aa8aa commit 60a0999
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/realtime/tenants/connect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ defmodule Realtime.Tenants.Connect do

error ->
log_error("UnableToStartHandler", error)
{:stop, :shutdown}
{:stop, :shutdown, state}
end
end

Expand Down Expand Up @@ -218,7 +218,10 @@ defmodule Realtime.Tenants.Connect do
) do
Logger.info("Tenant has no connected users, database connection will be terminated")
:ok = GenServer.stop(db_conn_pid, :normal, 500)
broadcast_changes_pid && GenServer.stop(broadcast_changes_pid, :normal, 500)

broadcast_changes_pid && Process.alive?(broadcast_changes_pid) &&
GenServer.stop(broadcast_changes_pid, :normal, 500)

{:stop, :normal, state}
end

Expand All @@ -228,7 +231,10 @@ defmodule Realtime.Tenants.Connect do
) do
Logger.warning("Tenant was suspended, database connection will be terminated")
:ok = GenServer.stop(db_conn_pid, :normal, 500)
broadcast_changes_pid && GenServer.stop(broadcast_changes_pid, :normal, 500)

broadcast_changes_pid && Process.alive?(broadcast_changes_pid) &&
GenServer.stop(broadcast_changes_pid, :normal, 500)

{:stop, :normal, state}
end

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.5",
version: "2.33.6",
elixir: "~> 1.16.0",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
1 change: 0 additions & 1 deletion test/realtime/broadcast_changes/handler_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ defmodule Realtime.BroadcastChanges.HandlerTest do
alias Realtime.Tenants.Migrations

setup do
Application.put_env(:realtime, :slot_name_suffix, random_string())
start_supervised(Realtime.Tenants.CacheSupervisor)
tenant = tenant_fixture()
[%{settings: settings} | _] = tenant.extensions
Expand Down

0 comments on commit 60a0999

Please sign in to comment.