Skip to content

fix(client): preserve ICE state in peer connection failure reports#2340

Open
jdimovska wants to merge 1 commit into
mainfrom
report-ice-state
Open

fix(client): preserve ICE state in peer connection failure reports#2340
jdimovska wants to merge 1 commit into
mainfrom
report-ice-state

Conversation

@jdimovska

@jdimovska jdimovska commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

💡 Overview

This PR fixes peer connection failure reporting by preserving the observed ICE connection state on client event telemetry. Previously, the reporter inferred ice_state from the type of failure callback, which could misreport DTLS failures as having connected ICE, or lose the ICE state captured when the peer connection pair opened. The change carries the live RTCPeerConnection.iceConnectionState through peer connection state-change events and uses it when completing PeerConnectionConnect failure reports.

📝 Implementation notes

🎫 Ticket: https://linear.app/stream/issue/XYZ-123

📑 Docs: https://github.com/GetStream/docs-content/pull/

Summary by CodeRabbit

  • Bug Fixes
    • Improved peer-connection failure reporting by preserving the latest ICE connection state.
    • More accurately distinguishes connected, failed, and not-connected states during connection and reconnection flows.
    • Ensures connection events consistently include the current ICE status for more reliable diagnostics.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4390220-3941-443d-b48c-d53b47b8abca

📥 Commits

Reviewing files that changed from the base of the PR and between a9b75d0 and c2e579e.

📒 Files selected for processing (4)
  • packages/client/src/reporting/ClientEventReporter.ts
  • packages/client/src/reporting/__tests__/ClientEventReporter.test.ts
  • packages/client/src/rtc/BasePeerConnection.ts
  • packages/client/src/rtc/types.ts

📝 Walkthrough

Walkthrough

Changes

Peer-connection events now include live ICE state. ClientEventReporter stores that state per pair, normalizes it for failure telemetry, and tests cover connected, failed, and not-connected outcomes across connection and reconnect flows.

ICE State Reporting

Layer / File(s) Summary
Propagate live ICE state
packages/client/src/rtc/types.ts, packages/client/src/rtc/BasePeerConnection.ts
Peer-connection state events expose and emit the current ICE connection state.
Store and normalize ICE state
packages/client/src/reporting/ClientEventReporter.ts
Peer-pair state retains ICE status, failure reporting derives normalized values, and cleanup paths use the updated API.
Validate state reporting scenarios
packages/client/src/reporting/__tests__/ClientEventReporter.test.ts
Tests use typed event helpers and cover ICE, DTLS, reconnect, and correlation scenarios.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RTCPeerConnection
  participant BasePeerConnection
  participant ClientEventReporter
  RTCPeerConnection->>BasePeerConnection: expose iceConnectionState
  BasePeerConnection->>ClientEventReporter: emit state change
  ClientEventReporter->>ClientEventReporter: store and normalize ICE state
  ClientEventReporter-->>RTCPeerConnection: report failure telemetry
Loading

Possibly related PRs

Suggested reviewers: oliverlaz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: preserving ICE state in peer connection failure reports.
Description check ✅ Passed The description matches the template with Overview, Implementation notes, Ticket, and Docs sections and clearly explains the change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch report-ice-state

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

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

@github-actions

Copy link
Copy Markdown

Bundle size

Built package output. Sizes in KB; delta vs main@ccb2273.

Package Unminified Minified Δ min vs main
@stream-io/video-client 743.7 KB 263.6 KB +136 B (+0.1%)
@stream-io/video-react-sdk 182.4 KB 89.6 KB 0 KB
↳ install total (+ client + react-bindings) 955.9 KB 362.3 KB +136 B (+0.0%)
@stream-io/video-react-native-sdk 402.5 KB 192.7 KB 0 KB
↳ install total (+ client + react-bindings) 1176.0 KB 465.4 KB +136 B (+0.0%)

@jdimovska
jdimovska requested a review from oliverlaz July 22, 2026 09:10
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.

1 participant