diff --git a/CHANGELOG.md b/CHANGELOG.md index f5688ee..5151284 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v19.4.0...HEAD) +### Fixed +* [STREAM-978](https://inindca.atlassian.net/browse/STREAM-978) - Fix an issue where a StanzaMediaSession would not be cleaned up when ICE connection failed. + ### Changed * [STREAM-941](https://inindca.atlassian.net/browse/STREAM-941) - Fix an issue where notifications.subscribe() with `enablePartialBulkResubscribe` would not resolve/reject based on API result when the requested topic was internally combined with others, e.g. "topic.a" and "topic.b" individually subscribed and bulk resubscribe combines them as "topic?a&b" * [STREAM-950](https://inindca.atlassian.net/browse/STREAM-950) - Update genesys-cloud-client-logger to pick up change moving from `unload` to `visibilitychange`. diff --git a/package-lock.json b/package-lock.json index e36f2dd..52d04a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "core-js": "^3.6.5", "debounce-promise": "^3.1.2", "exponential-backoff": "^3.1.1", - "genesys-cloud-client-logger": "^4.2.17", + "genesys-cloud-client-logger": "^4.2.18", "limiter": "^1.1.0", "lodash.throttle": "^4.1.1", "lru-cache": "^11.0.1", diff --git a/src/types/stanza-media-session.ts b/src/types/stanza-media-session.ts index cbca7a5..4115d08 100644 --- a/src/types/stanza-media-session.ts +++ b/src/types/stanza-media-session.ts @@ -202,6 +202,8 @@ export class StanzaMediaSession extends MediaSession implements IMediaSession { candidatesDiscovered: this.iceCandidatesDiscovered, candidatesReceivedFromPeer: this.iceCandidatesReceivedFromPeer }); + // Cleanup the session because failed is a state of finality. + this.end('failed-transport'); } super.onIceStateChange(); diff --git a/test/unit/stanza-media-session.test.ts b/test/unit/stanza-media-session.test.ts index e3f1386..b6f9f84 100644 --- a/test/unit/stanza-media-session.test.ts +++ b/test/unit/stanza-media-session.test.ts @@ -172,7 +172,7 @@ describe('StanzaMediaSession', () => { expect(spy).not.toHaveBeenCalled(); }); - it('should log ICE connection failed along with the number of candidates exchanged', () => { + it('should log ICE connection failed along with the number of candidates exchanged and cleanup.', () => { const parent = new FakeParent(); const session = new StanzaMediaSession({ options: { parent } as any, @@ -183,15 +183,17 @@ describe('StanzaMediaSession', () => { session['iceCandidatesDiscovered'] = 3; session['iceCandidatesReceivedFromPeer'] = 5; - const spy = session['_log'] = jest.fn(); + const logSpy = session['_log'] = jest.fn(); + const endSpy = jest.spyOn(session, 'end'); session['pc'] = { iceConnectionState: 'failed' } as any; session.onIceStateChange(); - expect(spy).toHaveBeenCalledWith('info', 'ICE connection failed', expect.objectContaining({ + expect(logSpy).toHaveBeenCalledWith('info', 'ICE connection failed', expect.objectContaining({ candidatesDiscovered: 3, candidatesReceivedFromPeer: 5 })); + expect(endSpy).toHaveBeenCalledWith('failed-transport'); }); it('should set interruption start', () => {