fix: nil pointer panic when destroying webrtc peer in profileChanged (#695)

* This is a no-op with the default configuration: when only a single video pipeline is configured, there is nothing for the stream selector to switch to. The change only has an effect when the operator configures multiple pipelines and enables the bandwidth estimator.

* fix(session): guard against nil WebRTC peer in profileChanged"

---------

Co-authored-by: alvarorichard <alvarorichard@tuta.io>
This commit is contained in:
KЯØNE
2026-08-29 08:46:35 -03:00
committed by GitHub
parent 393177f574
commit a7a217e607
+5 -1
View File
@@ -51,7 +51,11 @@ func (session *SessionCtx) profileChanged() {
// otherwise webrtc destroy would trigger websocket reconnect. In case of kick event, webrtc destroy is called
// before websocket destroy that delivers the information about the kick.
time.AfterFunc(time.Second, func() {
session.GetWebRTCPeer().Destroy()
// The peer may have been removed if the user disconnected while
// waiting for the delayed teardown.
if webrtcPeer := session.GetWebRTCPeer(); webrtcPeer != nil {
webrtcPeer.Destroy()
}
})
}