From 16e1c59e114aa806357450f6f500d35eea021df8 Mon Sep 17 00:00:00 2001 From: Valere Fedronic Date: Mon, 17 Nov 2025 18:22:37 +0100 Subject: [PATCH] playwright: Fix error boundary mgmt or openId errors (#3570) * playwright: Fix error boundary mgmt or openId errors * do not use tap for important logic * fix lint --------- Co-authored-by: Timo K --- .../localMember/LocalMembership.ts | 32 +++++++++++++++++-- .../localMember/LocalTransport.ts | 14 +++++--- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/state/CallViewModel/localMember/LocalMembership.ts b/src/state/CallViewModel/localMember/LocalMembership.ts index d9a3887b..26269985 100644 --- a/src/state/CallViewModel/localMember/LocalMembership.ts +++ b/src/state/CallViewModel/localMember/LocalMembership.ts @@ -22,6 +22,7 @@ import { ClientEvent, SyncState, type Room as MatrixRoom } from "matrix-js-sdk"; import { BehaviorSubject, combineLatest, + distinctUntilChanged, fromEvent, map, type Observable, @@ -41,7 +42,7 @@ import { type MuteStates } from "../../MuteStates"; import { type ProcessorState } from "../../../livekit/TrackProcessorContext"; import { type MediaDevices } from "../../MediaDevices"; import { and$ } from "../../../utils/observable"; -import { type ElementCallError } from "../../../utils/errors"; +import { ElementCallError, UnknownCallError } from "../../../utils/errors"; import { ElementWidgetActions, widget, @@ -52,7 +53,10 @@ import { getUrlParams } from "../../../UrlParams.ts"; import { PosthogAnalytics } from "../../../analytics/PosthogAnalytics.ts"; import { MatrixRTCMode } from "../../../settings/settings.ts"; import { Config } from "../../../config/Config.ts"; -import { type Connection } from "../remoteMembers/Connection.ts"; +import { + type Connection, + type ConnectionState, +} from "../remoteMembers/Connection.ts"; export enum LivekitState { Uninitialized = "uninitialized", @@ -446,8 +450,8 @@ export const createLocalMembership$ = ({ scope.reconcile(localTransport$, async (advertised) => { if (advertised !== null && advertised !== undefined) { try { - configError$.next(null); await enterRTCSession(matrixRTCSession, advertised, options.value); + configError$.next(null); } catch (e) { logger.error("Error entering RTC session", e); } @@ -477,6 +481,28 @@ export const createLocalMembership$ = ({ } }); + localConnection$ + .pipe( + distinctUntilChanged(), + switchMap((c) => + c === null ? of({ state: "Initialized" } as ConnectionState) : c.state$, + ), + map((s) => { + logger.trace(`Local connection state update: ${s.state}`); + if (s.state == "FailedToStart") { + return s.error instanceof ElementCallError + ? s.error + : new UnknownCallError(s.error); + } else { + return null; + } + }), + scope.bind(), + ) + .subscribe((fatalError) => { + configError$.next(fatalError); + }); + /** * Whether the user is currently sharing their screen. */ diff --git a/src/state/CallViewModel/localMember/LocalTransport.ts b/src/state/CallViewModel/localMember/LocalTransport.ts index 94c89deb..83c997e8 100644 --- a/src/state/CallViewModel/localMember/LocalTransport.ts +++ b/src/state/CallViewModel/localMember/LocalTransport.ts @@ -166,10 +166,14 @@ async function makeTransport( ): Promise { const transport = await makeTransportInternal(client, roomId); // this will call the jwt/sfu/get endpoint to pre create the livekit room. - await getSFUConfigWithOpenID( - client, - transport.livekit_service_url, - transport.livekit_alias, - ); + try { + await getSFUConfigWithOpenID( + client, + transport.livekit_service_url, + transport.livekit_alias, + ); + } catch (e) { + logger.warn(`Failed to get SFU config for transport: ${e}`); + } return transport; }