Log transient connect/transport failures as warnings in LogIfFailed#216
Merged
sierpinskid merged 1 commit intoJun 30, 2026
Conversation
The SDK fire-and-forgets its connect / reconnect / state-restore operations through TaskUtils.LogIfFailed (e.g. ConnectUserAsync(...).LogIfFailed(), RestoreStateLostDuringDisconnect().LogIfFailed(), the websocket ConnectAsync(...).LogIfFailed(_logs)). LogIfFailed logged every faulted task via Debug.LogException / Debug.LogError — i.e. at error severity. When the device is offline these fail with connectivity/transport exceptions (HttpRequestException / WebException / SocketException / IOException, and the ConnectAsync timeout's TimeoutException). They are expected, transient, and the reconnect flow recovers from them, so reporting them at error severity floods crash/error reporting (Sentry, Bugsnag, etc.) with handled, non-actionable noise. Classify those exception types and log them as warnings instead; genuine (non-connectivity) failures still surface as exceptions. Same rationale as the connection-attempt-timeout fix in GetStream#213, applied at the LogIfFailed logger that the REST connect/restore paths route through.
Member
sierpinskid
approved these changes
Jun 30, 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.

Summary
TaskUtils.LogIfFailedlogs every faulted fire-and-forget task at error severity (Debug.LogException/Debug.LogError). The SDK uses it on its connect / reconnect / state-restore operations:ConnectUserAsync(...).LogIfFailed()(reconnect path,StreamChatLowLevelClient)RestoreStateLostDuringDisconnect().LogIfFailed()(StreamChatClient)_websocketClient.ConnectAsync(connectionUri).LogIfFailed(_logs)(StreamChatLowLevelClient)DisconnectAsync().LogIfFailed(_logs)(NativeWebSocketWrapper)When the device is offline, these fail with connectivity/transport exceptions and get reported at error severity — flooding crash/error reporting (Sentry, Bugsnag, etc.) with handled, non-actionable noise. A representative production stack:
These are expected, transient failures that the reconnect flow recovers from — they shouldn't be logged as exceptions.
Change
LogIfFailed(both overloads) now classifies the fault: connectivity/transport exceptions are logged viaDebug.LogWarning, everything else staysDebug.LogException/Debug.LogError. A shared helper walks theAggregateException(flattened, plus each inner chain) for:System.Net.Http.HttpRequestExceptionSystem.Net.WebExceptionSystem.Net.Sockets.SocketExceptionSystem.IO.IOExceptionTimeoutExceptionGenuine (non-connectivity) failures are unaffected and still surface as exceptions.
Why this shape
This is the same rationale as #213 ("Log WebSocket connection-attempt timeout as a warning, not an exception"), applied at the
LogIfFailedlogger. #213 covered the WSTimeoutExceptioninsideHandleConnectionFailedAsync; this covers the REST connect/restore failures that fire-and-forget throughLogIfFailedand never reach that handler.Notes
or/is notpatterns), fully-qualified type names so no newusings are added.Unreleased / Fixes.