Skip to content

Keep the websocket connected when an event fails to parse after connecting - #6831

Merged
gpunto merged 1 commit into
developfrom
fix/socket-parse-failure-keeps-connection
Oct 15, 2026
Merged

gpunto merged 1 commit into
developfrom
fix/socket-parse-failure-keeps-connection

Conversation

@gpunto

@gpunto gpunto commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Goal

A websocket event that fails to parse made the client disconnect, reconnect and sync. When the same malformed event kept coming, the connection looped through reconnects. Drop and log such an event instead, as iOS does.

Closes AND-1660

Implementation

  • Once the connection event has been parsed, a frame that fails to parse and isn't an error is logged at error level (its event type and the parse error, never its content) and dropped. The connection stays up.
  • Before the connection, such a frame still fails the connect. Error frames are handled as before.
  • A dropped event's update is lost until the next sync.

Testing

  • StreamWebSocketTest covers a frame that fails to parse after connecting (dropped, the next event is delivered) and an error frame after connecting (still delivered). The existing case for a frame that fails before connecting is unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of malformed real-time events: after connection, unrecognized events are ignored so they don’t prevent subsequent valid events from being delivered.
    • Server error events continue to be reported, including after connection.

@gpunto gpunto added the pr:improvement Improvement label Oct 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.21 MB 6.21 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.52 MB 11.52 MB 0.00 MB 🟢
stream-chat-android-compose 13.18 MB 13.19 MB 0.00 MB 🟢
stream-chat-android-ai-compose 2.04 MB 2.04 MB 0.00 MB 🟢
stream-chat-android-ai-ondevice 1.67 MB 1.67 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

@gpunto
gpunto marked this pull request as ready for review October 15, 2026 12:47
@gpunto
gpunto requested a review from a team as a code owner October 15, 2026 12:47
@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b015bc32-c266-4ab9-92b0-387bf0419c48
📥 Commits

Reviewing files that changed from the base of the PR and between baa9870 and 3cc4d47.

📒 Files selected for processing: 2
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/socket/StreamWebSocket.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/socket/experimental/ws/StreamWebSocketTest.kt

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

StreamWebSocket now tracks whether it has received a ConnectedEvent. It emits recognized socket errors when parsing fails. Before connection, other parse failures produce CANT_PARSE_EVENT. After connection, those malformed frames are logged and dropped. The message callback emits only non-null parse results. New tests cover malformed and recognized error events after connection.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 3cc4d

The change is ready to merge after normal checks. No issue was found that would prevent malformed frames from being dropped while the connection continues.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description includes the required Goal, Implementation, and Testing sections. It explains the behavior before and after connection, error handling, logging, dropped updates, linked issue, and test…
Title check Passed The title clearly and concisely describes the main change: keeping the websocket connected when an event fails to parse after connection.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit taps the socket frame,
ConnectedEvent marks the state by name.
A known error hops into the stream,
A bad frame after connection leaves unseen.
The next good event arrives on cue,
The rabbit thumps: “The tests came through!”

Comment @coderabbitai help to get the list of available commands.

@aleksandar-apostolov aleksandar-apostolov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@gpunto
gpunto added this pull request to the merge queue Oct 15, 2026
Merged via the queue into develop with commit d163db5 Oct 15, 2026
20 of 21 checks passed
@gpunto
gpunto deleted the fix/socket-parse-failure-keeps-connection branch October 15, 2026 16:36
@stream-public-bot stream-public-bot added the released Included in a release label Oct 16, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Improvement released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants