Repository navigation
Fix WebSocket sends, lost requests and client lifetime - #5
Merged
dezinezync merged 2 commits intoOct 14, 2026
Merged
Conversation
Sends could report success without sending anything, requests could wait forever after a drop, and an abandoned client stayed in memory. - Throw from waiting sends when the client disconnects or gives up - Fail requests that are still waiting for a reply when the connection drops - Let a cancelled send stop waiting and clean up after itself - Deliver state changes in order - Release an abandoned client and close its connection - Add an optional ping interval (nil turns pings off) - Accept retry policies such as (2, 5, 8) that the old check rejected The existing initializer, default ping interval and auto-connect on send are unchanged. No public API breaks. All existing tests pass, and testTaskCancellation no longer fails intermittently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dezinezync
requested changes
Oct 14, 2026
Remove the chain that ran onStateChange calls in order, so state changes are delivered as before. Write the else-break guards in the receive and ping loops over multiple lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dezinezync
approved these changes
Oct 14, 2026
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.
Follow-up to #4.
Problem
disconnect()was called or the retry limit was reached, even though nothing was sent.send(message:responseType:)could reach the actor before the request was registered, so the request still returned successfully. This is whytestTaskCancellationwas flaky.ReconnectionPolicyrejected valid settings such as(2, 5, 8)and(2, 30, 60).Changes
All changes are in
DZWebSocketClient.swiftandReconnectionPolicy.swift.pingInterval(1 second to 1 day, ornilfor no pings). The existing initializer still pings every 10 seconds.ReconnectionPolicynow checks that delays are positive and finite and thatmaximumDelay >= baseDelay. The delay formulas are unchanged. It is alsoSendable.Compatibility
swift package diagnose-api-breaking-changes mainreports none.Testing
testTaskCancellationpassed 40/40 runs.mainand this branch using local test servers. These scenarios fail onmainand pass with this change:Known issues, for a follow-up PR
maximumDelaycan overflowDuration.listen()can miss messages that arrive before its handler is registered.🤖 Generated with Claude Code