From 07024010d8857dc2853be588e6cc763ffdd7cb3a Mon Sep 17 00:00:00 2001 From: Serhii Snozyk Date: Thu, 3 Sep 2026 19:35:00 +0200 Subject: [PATCH] fix: cancel the previous close timer when starting a handshake `send_close/2` overwrote `close_timer` without cancelling it, and `close/1` only cancels the timer it can see. Two handshakes inside the 5s window left the first timer armed, so it fired after the connection had been closed and re-established, and tore down the healthy connection. --- lib/minch/conn.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/minch/conn.ex b/lib/minch/conn.ex index 3e67371..8fdede1 100644 --- a/lib/minch/conn.ex +++ b/lib/minch/conn.ex @@ -273,6 +273,7 @@ defmodule Minch.Conn do defp send_close(%State{} = state, frame) do send_frame(state, frame) + cancel_timer(state.close_timer) %{state | websocket: nil, close_timer: internal_event({:close_timeout, frame}, 5000)} end