Skip to content

Conversation

@krushnarout
Copy link
Member

socket disconnect errors commonly occur during network changes or server restarts and are expected behavior. This change prevents treating them as crashes, reducing crashlytics noise

closes #3147

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to reduce noise in crash reporting by no longer treating socket errors as crashes. The change removes the crash report call from the socket's onError handler. While this achieves the goal for expected network disconnects, it also has the unintended side effect of suppressing crash reports for all other errors, including potentially critical application-level bugs. My review includes a suggestion to conditionally report crashes, ignoring only specific network-related exceptions, to ensure that unexpected errors are still captured.

});

_listener?.onError(err, trace);
PlatformManager.instance.crashReporter.reportCrash(err, trace);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Completely removing crash reporting is too broad and can hide legitimate application bugs. For instance, an exception in an onMessage handler would be caught here but would no longer be reported. It's better to conditionally report crashes, filtering out expected network errors like SocketException and WebSocketChannelException.

    // Only report unexpected errors as crashes, not common network issues.
    if (err is! SocketException && err is! WebSocketChannelException) {
      PlatformManager.instance.crashReporter.reportCrash(err, trace);
    }

@krushnarout krushnarout requested a review from mdmohsin7 January 8, 2026 08:17
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.

FlutterError - SocketException: Reading from a closed socket

2 participants