Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve EXITs that happen during calls #258

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/redix/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defmodule Redix.Connection do
resp

{:DOWN, ^request_id, _, _, reason} ->
exit(reason)
exit({:redix_exited_during_call, reason})
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/redix/connector.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
8 changes: 4 additions & 4 deletions test/redix/start_options_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions test/redix_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
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
Expand Down Expand Up @@ -571,7 +571,7 @@

# Regression for https://github.com/whatyouhide/redix/issues/192
@tag :capture_log
test "throw a human-readable error when the server disabled CLIENT commands and users " <>

Check failure on line 574 in test/redix_test.exs

View workflow job for this annotation

GitHub Actions / Test (Elixir 1.11.2 | Erlang/OTP 23.0)

test noreply_* functions throw a human-readable error when the server disabled CLIENT commands and users of Redix ignore function results (RedixTest)
"of Redix ignore function results" do
conn = start_supervised!({Redix, port: 6386})
Process.flag(:trap_exit, true)
Expand All @@ -584,7 +584,8 @@
# 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"
Expand Down
Loading