diff --git a/src/screenviewing/DefaultScreenViewing.ts b/src/screenviewing/DefaultScreenViewing.ts index d30d410db5..38fe594f58 100644 --- a/src/screenviewing/DefaultScreenViewing.ts +++ b/src/screenviewing/DefaultScreenViewing.ts @@ -29,7 +29,11 @@ export default class DefaultScreenViewing implements ScreenViewing { * Stops screen viewing and closes the screen signaling connection */ close(): Promise { - return this.stop().then(() => this.componentContext.signalingSession.close()); + return this.stop() + .catch(() => {}) + .finally(() => { + return this.componentContext.signalingSession.close(); + }); } /** diff --git a/test/screenviewing/DefaultScreenViewing.test.ts b/test/screenviewing/DefaultScreenViewing.test.ts index 559bdd7720..5e6e7ae780 100644 --- a/test/screenviewing/DefaultScreenViewing.test.ts +++ b/test/screenviewing/DefaultScreenViewing.test.ts @@ -29,6 +29,30 @@ describe('DefaultScreenViewing', () => { }); describe('close', () => { + describe('with error', () => { + it('is closed', () => { + return new DefaultScreenViewing({ + ...Substitute.for(), + viewer: { + ...Substitute.for(), + stop(): void {}, + }, + signalingSession: { + ...Substitute.for(), + close(): Promise { + return Promise.resolve(); + }, + }, + viewingSession: { + ...Substitute.for(), + closeConnection(): Promise { + return Promise.reject(new Error('bummers')); + }, + }, + }).close(); + }); + }); + it('calls viewer close', () => { return new DefaultScreenViewing({ ...Substitute.for(),