Skip to content

api: throw error in addIceCandidate when peer connection is closed#14

Open
MiloszFilimowski wants to merge 1 commit intofishjam-cloud:masterfrom
react-native-webrtc:master
Open

api: throw error in addIceCandidate when peer connection is closed#14
MiloszFilimowski wants to merge 1 commit intofishjam-cloud:masterfrom
react-native-webrtc:master

Conversation

@MiloszFilimowski
Copy link
Collaborator

Browsers (Chrome, Firefox, Safari) throw an InvalidStateError when addIceCandidate is called on a closed RTCPeerConnection, as per the W3C WebRTC spec. This change aligns react-native-webrtc with that behavior by throwing an error instead of silently proceeding.

This is consistent with how addTrack and removeTrack already handle the closed state in this codebase.

Fixes: react-native-webrtc#1795

Browsers (Chrome, Firefox, Safari) throw an InvalidStateError when
addIceCandidate is called on a closed RTCPeerConnection, as per the
W3C WebRTC spec. This change aligns react-native-webrtc with that
behavior by throwing an error instead of silently proceeding.

This is consistent with how addTrack and removeTrack already handle
the closed state in this codebase.

Fixes: #1795
Copilot AI review requested due to automatic review settings March 5, 2026 16:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns react-native-webrtc's addIceCandidate behavior with the W3C WebRTC spec and with browser implementations (Chrome, Firefox, Safari) by throwing an error when the method is called on a closed RTCPeerConnection, instead of silently proceeding into native module calls.

Changes:

  • Adds a closed-state guard at the start of addIceCandidate, throwing new Error('Peer Connection is closed') — matching the identical check already used by addTrack and removeTrack.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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.

addIceCandidate should guard against closed connectionState

3 participants