Skip to content

deps(grpc): bump optional gun to 2.8.0 - #661

Merged
polvalente merged 3 commits into
elixir-grpc:masterfrom
edisonywh:bump-gun-2.8
Nov 20, 2026
Merged

polvalente merged 3 commits into
elixir-grpc:masterfrom
edisonywh:bump-gun-2.8

Conversation

@edisonywh

Copy link
Copy Markdown
Contributor

Fixes #660.

grpc pinned {:gun, "~> 2.7.0", optional: true}. Gun 2.7.0 does not handle the value that cowlib 2.22.0 returns for DATA on a reset stream, so on cowlib 2.22.0 a client-side cancel can crash the gun connection process and fail every other RPC on that channel. Gun 2.8.0 handles it and requires cowlib 2.22.0.

Changes

  • grpc/mix.exs: {:gun, "~> 2.8.0", optional: true}.
  • gun 2.7.0 -> 2.8.0, cowlib 2.21.0 -> 2.22.0 and cowboy 2.20.0 -> 2.21.0 in grpc/mix.lock, grpc_server/mix.lock and interop/mix.lock, made with mix deps.update gun cowlib cowboy. The root mix.lock has no gun dependency (its gun entry is stale, as in deps(grpc): bump optional gun to 2.7.0 #616), so I copied the new gun line from grpc/mix.lock; cowboy and cowlib there come from mix.
  • Cowboy moves because cowboy 2.20.0 has no clause for cowlib 2.22's window_changed return value. Cowboy 2.21.0 has it and requires cowlib 2.22.0. Mix also wanted to move ranch, grpc_core and telemetry; I left those entries as they were on master.
  • grpc_server tests: cowlib 2.22.0 changes cow_http2:parse/1 to return DATA frames as a 5-tuple {data, StreamID, Fin, Data, Flow}. Two raw HTTP/2 tests matched the 4-tuple and failed (cowboy_connection_age_test.exs, cowboy_connection_idle_test.exs), and two more patterns (body_limit_flow_window_test.exs, send_backpressure_test.exs) could no longer match. They are in a second commit.
  • Changelog entry under Behavior Changes.

Tests

Run locally on OTP 28.5 / Elixir 1.20.1, on master first and then on this branch:

Check master this branch
mix format --check-formatted passes passes
grpc: mix test 705 passed (13 doctests, 692 tests), 2 skipped 705 passed (13 doctests, 692 tests), 2 skipped
grpc_server: mix test 373 passed (2 doctests, 371 tests) 373 passed (2 doctests, 371 tests)
grpc: elixir script/adapter_test.exs gun passes passes
interop: mix run script/run.exs exits 0 exits 0

Also run on the branch, matching what CI runs from the repo root: MIX_ENV=test mix compile --warnings-as-errors passes; mix test --warnings-as-errors passes (grpc_core 134, grpc_server 373, grpc 702 passed, 2 skipped); mix test --only warning_test passes (3 tests); elixir script/adapter_test.exs mint passes. These all pass, so I did not run them on master. With OTP 27.3.4.13 / Elixir 1.19.5 and OTP 29.0.5 / Elixir 1.20.3, grpc_server passes (373) on both and grpc on 29 (705 passed, 2 skipped). On 27, grpc had one failure in one run (connection_test.exs:267, a process-leak assertion in a test that does not use gun versions); it did not come back in 3 isolated reruns or a full rerun (0 failures), and master on 27 also passed a full run, so I take it as a flaky test, not caused by this change.

Before the test fix, grpc_server on this branch had 2 failures out of 373, reproducibly (3 of 3 reruns). They also fail with cowboy 2.20.0 and cowlib 2.22.0, so they come from cowlib 2.22.0 and not from cowboy.

To check that the bump is what fixes the crash, I ran one scenario with three dependency sets, 5 runs each. One gun channel, a slow unary RPC in flight, and a bidirectional RPC that floods 16 KB messages and is cancelled client-side after 3 messages:

Dependencies Result (5 runs each)
gun 2.7.0, cowlib 2.21.0, cowboy 2.20.0 (master lock) slow RPC returns ok, gun process stays up
gun 2.7.0, cowlib 2.22.0, cowboy 2.21.0 gun process dies with case_clause {window_changed, ...} at gun_http2.erl:323, slow RPC fails with UNAVAILABLE
gun 2.8.0, cowlib 2.22.0, cowboy 2.21.0 (this branch) slow RPC returns ok, gun process stays up

The same split came out of a gun-and-cowboy-only version of the scenario. The scenario scripts are not part of this PR; I can add one as a regression test if you want it.

Notes

  • Gun 2.8.0 still requires Erlang/OTP 27.0 or greater, the same floor as 2.7 (gun's migration guide). The guide also lists a potential incompatibility: the HTTP/2 option max_header_list_size now defaults to 32768, and cowlib 2.22.0 enforces it. Grpc does not set it.
  • Master's script/adapter_test.exs gun already resolves gun 2.7.0 with cowlib 2.22.0, because Mix.install has no lock. It passes there only because it connects and never cancels a stream.
  • grpc_server/mix.exs still allows cowlib ~> 2.21 and cowboy ~> 2.14. With cowlib 2.22.0 and cowboy older than 2.21.0 the server side lacks the window_changed clause (read in the source, not reproduced), and the updated tests no longer match cowlib 2.21 frames. I left the requirements alone to keep this PR small; say if you want them raised here.
  • Mix also wanted to move ranch, grpc_core and telemetry in some lock files. I left those entries as they were on master.

Not verified

  • The security fixes in cowlib 2.22.0. Gun's 2.8 guide calls it a maintenance release, and cowlib has no release notes or migration guide, only commit messages.
  • A server-side crash of cowboy 2.20.0 with cowlib 2.22.0.
  • Mint beyond adapter_test.exs mint connecting, and OTP 27.3 / 29.0 beyond the grpc and grpc_server suites.
  • CI itself: OTP 27 uses Elixir 1.17 there, and I did not have that pair.

🤖 Generated with Claude Code

edisonywh and others added 2 commits November 19, 2026 10:14
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@polvalente
polvalente merged commit 309b29e into elixir-grpc:master Nov 20, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bump optional gun to 2.8 (needs cowlib 2.22), and a question about a wider gun requirement

2 participants