Repository navigation
Conversation
`push/5` is a `GenServer.call/3` to the connection process, but the call
was not guarded, so:
* a push which was not accepted within `timeout` (e.g. the connection
process is busy or blocked writing to the socket) exited the client
process with `{:timeout, {GenServer, :call, _}}`
* a connection process which exited or stopped during the call (e.g. a
send failure, which stopped the connection without replying) exited the
client process too
The code comment above the fallback clause expected these to be returned
as errors. `Socket.call/3` now catches the exits and `push/5` returns
`{:error, :timeout}` or `{:error, :not_connected}`, and a send failure
during a push replies `{:error, {:send_failure, reason}}` before the
connection stops.
Payloads are also encoded in the connection process, so a push or join
whose params the serializer could not encode (e.g. a map containing a pid,
or a topic over 255 bytes for a binary push) raised and crashed the
connection. A push now returns `{:error, %Slipstream.Serializer.EncodeError{}}`
and a join fails with `{:failed_to_join, {:encode_error, exception}}`;
the connection stays up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
push/5is aGenServer.call/3to the connection process (lib/slipstream/command_router.ex:54,lib/slipstream/socket.ex:240), and the call isn't guarded:timeoutexits the client process with{:timeout, {GenServer, :call, _}}. That happens when the connection is busy, or blocked in a socket write as in Connection can block indefinitely on a stalled send (no send_timeout), defeating heartbeat self-heal and growing the process heap until OOM #85.The comment above the fallback clause in
push/5(lib/slipstream.ex:1094) expected these to come back as errors.Separately, payloads are encoded inside the connection process. A push or join whose params the serializer can't encode raises there and kills the connection; examples are a map containing a pid, or a topic longer than 255 bytes for a binary push.
Reproduction
Changes
Socket.call/3catches exits, sopush/5returns{:error, :timeout}or{:error, :not_connected}instead.{:error, {:send_failure, reason}}before the connection stops.{:error, %Slipstream.Serializer.EncodeError{}}, and the connection stays up.{:failed_to_join, {:encode_error, exception}}throughhandle_topic_close/3/await_join/3, and the connection stays up.push/5docs.Slipstream.SocketTest.assert_push/5is unchanged.Compatibility
push/5no longer exits the caller in these cases; it returns an error. On OTP 24+ a late reply after a timeout is dropped (calls use process aliases), so no stray message arrives in the client's mailbox.Related to #76: in test mode, a push from
handle_call/3while the test process is blocked now returns{:error, :timeout}instead of crashing the client. The deadlock itself remains, as discussed there.How this was found, and AI use
I found this during a review of Slipstream's memory and timeout behaviour that I did with Claude Code. Claude reproduced the client exit against
mainwhile testing the blocked-send case from #85, and wrote this change and its tests.