Skip to content

Commit 518c8ea

Browse files
committed
Finish the hangup procedure even if widget API throws errors
1 parent a75952c commit 518c8ea

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/rtcSessionHelpers.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ const widgetPostHangupProcedure = async (
144144
// We send the hangup event after the memberships have been updated
145145
// calling leaveRTCSession.
146146
// We need to wait because this makes the client hosting this widget killing the IFrame.
147-
await widget.api.transport.send(ElementWidgetActions.HangupCall, {});
147+
try {
148+
await widget.api.transport.send(ElementWidgetActions.HangupCall, {});
149+
} catch (e) {
150+
logger.error("Failed to send hangup action", e);
151+
}
148152
// On a normal user hangup we can shut down and close the widget. But if an
149153
// error occurs we should keep the widget open until the user reads it.
150154
if (cause === "user") {
151-
await widget.api.transport.send(ElementWidgetActions.Close, {});
155+
try {
156+
await widget.api.transport.send(ElementWidgetActions.Close, {});
157+
} catch (e) {
158+
logger.error("Failed to send close action", e);
159+
}
152160
widget.api.transport.stop();
153161
PosthogAnalytics.instance.logout();
154162
}

0 commit comments

Comments
 (0)