Skip to content
Open
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
1 change: 1 addition & 0 deletions grpc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Behavior Changes

* The Mint adapter now enforces the requested `:timeout`/`:deadline` on unary receives. A unary call that never receives a response fails with `DEADLINE_EXCEEDED` after the documented 10s default instead of blocking indefinitely, and an explicit `:deadline` now takes precedence over `:timeout`.
* `GRPC.Client.Adapters.Mint.connect/2` now returns errors directly, instead of formatting as a string.

### Bug Fixes

Expand Down
10 changes: 3 additions & 7 deletions grpc/lib/grpc/client/adapters/mint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,11 @@ if Code.ensure_loaded?(Mint.HTTP) do
|> mint_scheme()
|> ConnectionProcess.start_link(host, port, opts)
|> case do
{:ok, pid} ->
{:ok, %{channel | adapter_payload: %{conn_pid: pid}}}

error ->
{:error, "Error while opening connection: #{inspect(error)}"}
{:ok, pid} -> {:ok, %{channel | adapter_payload: %{conn_pid: pid}}}
error -> error
end
catch
:exit, reason ->
{:error, "Error while opening connection: #{inspect(reason)}"}
:exit, reason -> {:error, reason}
end

@impl true
Expand Down
8 changes: 2 additions & 6 deletions grpc/test/grpc/adapters/mint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ defmodule GRPC.Client.Adapters.MintTest do
assert %{channel | adapter_payload: %{conn_pid: result.adapter_payload.conn_pid}} == result

# Ensure that changing one of the options breaks things
assert {:error, message} = Mint.connect(channel, transport_opts: [ip: "256.0.0.0"])

assert message == "Error while opening connection: {:error, :badarg}"
assert {:error, :badarg} = Mint.connect(channel, transport_opts: [ip: "256.0.0.0"])
end

test "accepts config_options for application specific configuration", %{port: port} do
Expand All @@ -42,10 +40,8 @@ defmodule GRPC.Client.Adapters.MintTest do
assert %{channel | adapter_payload: %{conn_pid: result.adapter_payload.conn_pid}} == result

# Ensure that changing one of the options via config_options also breaks things
assert {:error, message} =
assert {:error, :badarg} =
Mint.connect(channel, config_options: [transport_opts: [ip: "256.0.0.0"]])

assert message == "Error while opening connection: {:error, :badarg}"
end

test "defaults client settings when none is passed", %{port: port} do
Expand Down
Loading