Skip to content

fix: cancel the previous close timer when starting a handshake - #93

Closed
nmbrone wants to merge 1 commit into
mainfrom
fix/close-timer-leak
Closed

fix: cancel the previous close timer when starting a handshake#93
nmbrone wants to merge 1 commit into
mainfrom
fix/close-timer-leak

Conversation

@nmbrone

@nmbrone nmbrone commented Sep 3, 2026

Copy link
Copy Markdown
Owner

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 — a server close frame arriving, then a callback returning {:close, code, reason, state} before the socket drops — left the first timer armed. It fired after the connection had been closed and re-established, tearing down the healthy connection.

No test: observing it black-box means waiting out the 5s timer and catching a spurious disconnect on the reconnected client. The alternatives are a 5s test, reading a private timer ref via :sys.get_state, or making the timeout configurable purely for tests — none of which seemed worth it for a one-line fix.

`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.
@nmbrone

nmbrone commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

Folded into #92 — the timer cancel is what makes the new :close_timeout well defined, and the squashed commit carries its own fix: entry so it still gets a changelog line. Branch left in place.

@nmbrone nmbrone closed this Sep 3, 2026
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.

1 participant