feat: Report a server-initiated stream close to the connection error handler - #118
Merged
Merged
Conversation
tanderson-ld
approved these changes
Sep 29, 2026
jsonbailey
approved these changes
Sep 29, 2026
beekld
pushed a commit
that referenced
this pull request
Sep 29, 2026
🤖 I have created a release *beep* *boop* --- ## [3.4.0](3.3.1...3.4.0) (2026-09-29) ### Features * Report a server-initiated stream close to the connection error handler ([#118](#118)) ([30558a4](30558a4)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **Release 3.4.0** — bumps the library version across the manifest, CocoaPods spec, Xcode project, README install pins, and adds a **3.4.0** entry to `CHANGELOG.md`. > > This tag documents the functional change from [#118](#118): when the server ends an open SSE connection without a URL error, the client now invokes `connectionErrorHandler` with `StreamClosedByServerError` (instead of only logging and reconnecting). Handlers can return `.shutdown` to stop retries, matching other connection failures. > > No Swift source edits appear in this PR; it is release metadata only. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 163099e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: LaunchDarklyReleaseBot <LaunchDarklyReleaseBot@launchdarkly.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.
Summary
EventSourcenow treats a close of the stream by the server as a connection failure, and reports it to theConnectionErrorHandleras a newStreamClosedByServerError. Previously it did not treat that close as a failure, so the handler never ran and could not replace the built-in reconnect.Because the default
ConnectionErrorHandlerreturns.proceed, a consumer that does not set one now also receives the close throughEventHandler.onError.Note
Overview
When the SSE stream ends without a URL error (server closes the connection cleanly), the client now treats that as a connection failure and routes it through the same path as other connection errors.
A new public
StreamClosedByServerErroris introduced for that case.didCompleteWithErroris refactored so both transport errors and server-initiated closes set aconnectionError, then calldispatchErroronce—soconnectionErrorHandlerand (by default)EventHandler.onErrorrun before reconnect. Client-initiated cancels (NSURLErrorCancelledfromstop()) are still ignored and do not surface as this error.Tests expect
StreamClosedByServerErroron normal stream finish and cover reconnect,.shutdownfrom the error handler, and thatstop()does not report an error.Reviewed by Cursor Bugbot for commit 1e8dc59. Bugbot is set up for automated code reviews on this repo. Configure here.