From 60a099940799f765a569603d6917b3793ad319b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Sat, 19 Oct 2024 09:47:07 +0100 Subject: [PATCH] fix: Properly handle error on handle_continue (#1171) --- lib/realtime/tenants/connect.ex | 12 +++++++++--- mix.exs | 2 +- test/realtime/broadcast_changes/handler_test.exs | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/realtime/tenants/connect.ex b/lib/realtime/tenants/connect.ex index d5c7950e5..27c6535cd 100644 --- a/lib/realtime/tenants/connect.ex +++ b/lib/realtime/tenants/connect.ex @@ -180,7 +180,7 @@ defmodule Realtime.Tenants.Connect do error -> log_error("UnableToStartHandler", error) - {:stop, :shutdown} + {:stop, :shutdown, state} end end @@ -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 @@ -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 diff --git a/mix.exs b/mix.exs index d66c30845..793ff2c6d 100644 --- a/mix.exs +++ b/mix.exs @@ -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, diff --git a/test/realtime/broadcast_changes/handler_test.exs b/test/realtime/broadcast_changes/handler_test.exs index 595ddbc69..2a4506fea 100644 --- a/test/realtime/broadcast_changes/handler_test.exs +++ b/test/realtime/broadcast_changes/handler_test.exs @@ -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