diff --git a/src/models/Call.ts b/src/models/Call.ts index 2b996c96c3c..eaee7df2e8b 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -255,6 +255,7 @@ export abstract class Call extends TypedEventEmitter { + if (uid === this.widgetUid) { + logger.log("The widget died; treating this as a user hangup"); + this.setDisconnected(); + } + }; + private beforeUnload = () => this.setDisconnected(); } diff --git a/test/models/Call-test.ts b/test/models/Call-test.ts index ad6bb362ddb..17f4fbfc4a1 100644 --- a/test/models/Call-test.ts +++ b/test/models/Call-test.ts @@ -784,6 +784,13 @@ describe("ElementCall", () => { expect(call.connectionState).toBe(ConnectionState.Connected); }); + it("disconnects if the widget dies", async () => { + await call.connect(); + expect(call.connectionState).toBe(ConnectionState.Connected); + WidgetMessagingStore.instance.stopMessaging(widget, room.roomId); + expect(call.connectionState).toBe(ConnectionState.Disconnected); + }); + it("tracks participants in room state", async () => { expect(call.participants).toEqual(new Map());