Repository: whatyouhide/redix
Pull request #258 (2023-10-18 16:28:39)

Improve EXITs that happen during calls


Patch:
diff --git a/lib/redix/connection.ex b/lib/redix/connection.ex
index e95265f..a8208d3 100644
--- a/lib/redix/connection.ex
+++ b/lib/redix/connection.ex
@@ -82,7 +82,7 @@ defmodule Redix.Connection do
         resp
 
       {:DOWN, ^request_id, _, _, reason} ->
-        exit(reason)
+        exit({:redix_exited_during_call, reason})
     end
   end
 
diff --git a/lib/redix/connector.ex b/lib/redix/connector.ex
index a331f7c..81cc984 100644
--- a/lib/redix/connector.ex
+++ b/lib/redix/connector.ex
@@ -79,7 +79,7 @@ defmodule Redix.Connector do
       # Redis gives use. The only alternative left would be to provide an explicit :use_username
       # option but that feels very orced on the user.
       {:error, %Redix.Error{message: "ERR wrong number of arguments for 'auth' command"}} ->
-        Logger.warn("""
+        Logger.warning("""
         a username was provided to connect to Redis (either via options or via a URI). However, \
         the Redis server version for this connection seems to not support ACLs, which are only \
         supported from Redis version 6.0.0 (https://redis.io/topics/acl). Earlier versions of \


Test patch:
diff --git a/test/redix/start_options_test.exs b/test/redix/start_options_test.exs
index 4e6b016..193db74 100644
--- a/test/redix/start_options_test.exs
+++ b/test/redix/start_options_test.exs
@@ -118,8 +118,8 @@ defmodule Redix.StartOptionsTest do
       sentinels = opts[:sentinel][:sentinels]
 
       assert Enum.count(sentinels) == 2
-      assert Enum.find(sentinels, &(&1[:host] == 'host1'))[:password] == "secret1"
-      assert Enum.find(sentinels, &(&1[:host] == 'host2'))[:password] == "secret2"
+      assert Enum.find(sentinels, &(&1[:host] == ~c"host1"))[:password] == "secret1"
+      assert Enum.find(sentinels, &(&1[:host] == ~c"host2"))[:password] == "secret2"
     end
 
     test "sentinel password mfa" do
@@ -141,8 +141,8 @@ defmodule Redix.StartOptionsTest do
       sentinels = opts[:sentinel][:sentinels]
 
       assert Enum.count(sentinels) == 2
-      assert Enum.find(sentinels, &(&1[:host] == 'host1'))[:password] == mfa1
-      assert Enum.find(sentinels, &(&1[:host] == 'host2'))[:password] == mfa2
+      assert Enum.find(sentinels, &(&1[:host] == ~c"host1"))[:password] == mfa1
+      assert Enum.find(sentinels, &(&1[:host] == ~c"host2"))[:password] == mfa2
     end
 
     test "gen_statem options are allowed" do
diff --git a/test/redix_test.exs b/test/redix_test.exs
index 55a078a..91664fb 100644
--- a/test/redix_test.exs
+++ b/test/redix_test.exs
@@ -361,7 +361,7 @@ defmodule RedixTest do
       Process.exit(conn, :kill)
 
       assert_receive {:EXIT, ^conn, :killed}
-      assert_receive {:EXIT, ^pid, :killed}
+      assert_receive {:EXIT, ^pid, {:redix_exited_during_call, :killed}}
     end
 
     test "passing a non-list as the command", %{conn: c} do
@@ -584,7 +584,8 @@ defmodule RedixTest do
       # with a hard-to-understand error (see the issue linked above).
       _ = Redix.noreply_command(conn, ["INCR", key])
 
-      assert {%RuntimeError{} = error, _stacktrace} = catch_exit(Redix.command!(conn, ["PING"]))
+      assert {:redix_exited_during_call, {%RuntimeError{} = error, _stacktrace}} =
+               catch_exit(Redix.command!(conn, ["PING"]))
 
       assert Exception.message(error) =~
                "failed to find an original command in the commands queue"