From a52029abfb42cc09c0ff4dcf3a2060fda49a6768 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 9 Dec 2024 17:53:05 +0100 Subject: [PATCH 1/4] Prevent undefined access to engine in connection reconciler --- src/room/Room.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/room/Room.ts b/src/room/Room.ts index 6319d1768d..0da26a55bf 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -1904,7 +1904,7 @@ class Room extends (EventEmitter as new () => TypedEmitter) ...this.logContext, numFailures: consecutiveFailures, engine: { - closed: this.engine.isClosed, + closed: !!this.engine?.isClosed, transportsConnected: this.engine.verifyTransport(), }, }); From cbb85d1daf6bf84773b23dc95d40e5ee1e95e7bc Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 9 Dec 2024 17:53:35 +0100 Subject: [PATCH 2/4] Create red-maps-happen.md --- .changeset/red-maps-happen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/red-maps-happen.md diff --git a/.changeset/red-maps-happen.md b/.changeset/red-maps-happen.md new file mode 100644 index 0000000000..a21108df2a --- /dev/null +++ b/.changeset/red-maps-happen.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Prevent undefined access to engine in connection reconciler From a2dacc00d7eec01824852e0262e875eaaa66e9bf Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 9 Dec 2024 17:55:01 +0100 Subject: [PATCH 3/4] also transports --- src/room/Room.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/room/Room.ts b/src/room/Room.ts index 0da26a55bf..33e8978923 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -1905,7 +1905,7 @@ class Room extends (EventEmitter as new () => TypedEmitter) numFailures: consecutiveFailures, engine: { closed: !!this.engine?.isClosed, - transportsConnected: this.engine.verifyTransport(), + transportsConnected: !!this.engine?.verifyTransport(), }, }); if (consecutiveFailures >= 3) { From 61cd821d81402bd128ff70c25feb7d74709bc7af Mon Sep 17 00:00:00 2001 From: lukasIO Date: Mon, 9 Dec 2024 17:57:57 +0100 Subject: [PATCH 4/4] set engine undefined if it's undefined2 --- src/room/Room.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/room/Room.ts b/src/room/Room.ts index 33e8978923..effcb84a64 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -1903,10 +1903,12 @@ class Room extends (EventEmitter as new () => TypedEmitter) this.log.warn('detected connection state mismatch', { ...this.logContext, numFailures: consecutiveFailures, - engine: { - closed: !!this.engine?.isClosed, - transportsConnected: !!this.engine?.verifyTransport(), - }, + engine: this.engine + ? { + closed: this.engine.isClosed, + transportsConnected: this.engine.verifyTransport(), + } + : undefined, }); if (consecutiveFailures >= 3) { this.recreateEngine();