From d2fd537657089a3b9b0d5948edccc839803fdaea Mon Sep 17 00:00:00 2001 From: Joao Santos Date: Mon, 14 Jul 2025 14:24:00 -0300 Subject: [PATCH] disconnect on error --- .gitignore | 2 ++ packages/common/src/webrtc/BaseCall.ts | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index fca7fc54..fe753915 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ Thumbs.db dist .devcontainer/devcontainer.json .devcontainer/Dockerfile +.claude/ +CLAUDE.md diff --git a/packages/common/src/webrtc/BaseCall.ts b/packages/common/src/webrtc/BaseCall.ts index 090a6f78..7f1f7b30 100644 --- a/packages/common/src/webrtc/BaseCall.ts +++ b/packages/common/src/webrtc/BaseCall.ts @@ -832,8 +832,8 @@ export default abstract class BaseCall implements IWebRTCCall { }) .catch((error) => { logger.error('Call setRemoteDescription Error: ', error) - this.hangup() - }) + this._disconnectAndReconnect() + }) } private _requestAnotherLocalDescription() { @@ -902,7 +902,7 @@ export default abstract class BaseCall implements IWebRTCCall { }) .catch((error) => { logger.error(`${this.id} - Sending ${type} error:`, error) - this.hangup() + this._disconnectAndReconnect() }) } @@ -985,6 +985,13 @@ export default abstract class BaseCall implements IWebRTCCall { } } + private _disconnectAndReconnect() { + logger.debug(`${this.id} - Triggering WebSocket reconnection due to error`) + // Trigger a socket error event which will cause the session to reconnect + // The BaseSession's _onSocketCloseOrError handler will automatically reconnect + trigger(SwEvent.SocketError, { type: 'error', message: 'Forced reconnection due to call error' }, this.session.uuid) + } + private _execute(msg: BaseMessage) { if (this.nodeId) { msg.targetNodeId = this.nodeId