Skip to content

Commit

Permalink
add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslandoga committed Oct 31, 2024
1 parent 02e24e8 commit 25f4b54
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/ch/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ defmodule Ch.Connection do
{:error, reason}
end
end
catch
_kind, reason -> {:error, reason}
end

@impl true
Expand Down
19 changes: 14 additions & 5 deletions test/ch/connect_test.exs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
defmodule Ch.ConnectTest do
use ExUnit.Case, async: true
use ExUnit.Case
import ExUnit.CaptureLog

@tag :slow
test "retries to connect even with exceptions" do
{:ok, conn} =
Ch.start_link(database: Ch.Test.database(), transport_opts: [sndbuf: nil])
# See https://github.com/plausible/ch/issues/208
bad_transport_opts = [sndbuf: nil]

:timer.sleep(100)
logs =
capture_log(fn ->
{:ok, conn} =
Ch.start_link(database: Ch.Test.database(), transport_opts: bad_transport_opts)

assert Process.alive?(conn)
:timer.sleep(100)

assert Process.alive?(conn)
end)

assert logs =~ "failed to connect: ** (ArgumentError) argument error"
end
end

0 comments on commit 25f4b54

Please sign in to comment.