From f879a416d68ca6ace5f84ccfec49821fb2a343d2 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 11 Dec 2025 14:28:04 +0000 Subject: [PATCH] Fix test --- .../localMember/LocalTransport.test.ts | 12 ++++++++---- .../CallViewModel/localMember/LocalTransport.ts | 14 +++++++++++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/state/CallViewModel/localMember/LocalTransport.test.ts b/src/state/CallViewModel/localMember/LocalTransport.test.ts index 12f1121b..00d1d037 100644 --- a/src/state/CallViewModel/localMember/LocalTransport.test.ts +++ b/src/state/CallViewModel/localMember/LocalTransport.test.ts @@ -32,7 +32,8 @@ describe("LocalTransport", () => { memberships$: constant(new Epoch([])), client: { getDomain: () => "", - _unstable_getRTCTransports: async () => [], + // eslint-disable-next-line @typescript-eslint/naming-convention + _unstable_getRTCTransports: async () => Promise.resolve([]), // These won't be called in this error path but satisfy the type getOpenIdToken: vi.fn(), getDeviceId: vi.fn(), @@ -68,7 +69,8 @@ describe("LocalTransport", () => { client: { // Use empty domain to skip .well-known and use config directly getDomain: () => "", - _unstable_getRTCTransports: async () => [], + // eslint-disable-next-line @typescript-eslint/naming-convention + _unstable_getRTCTransports: async () => Promise.resolve([]), getOpenIdToken: vi.fn(), getDeviceId: vi.fn(), }, @@ -105,7 +107,8 @@ describe("LocalTransport", () => { memberships$: constant(new Epoch([])), client: { getDomain: () => "", - _unstable_getRTCTransports: async () => [], + // eslint-disable-next-line @typescript-eslint/naming-convention + _unstable_getRTCTransports: async () => Promise.resolve([]), getOpenIdToken: vi.fn(), getDeviceId: vi.fn(), }, @@ -141,7 +144,8 @@ describe("LocalTransport", () => { memberships$, client: { getDomain: () => "", - _unstable_getRTCTransports: async () => [], + // eslint-disable-next-line @typescript-eslint/naming-convention + _unstable_getRTCTransports: async () => Promise.resolve([]), getOpenIdToken: vi.fn(), getDeviceId: vi.fn(), }, diff --git a/src/state/CallViewModel/localMember/LocalTransport.ts b/src/state/CallViewModel/localMember/LocalTransport.ts index 7daae36d..7796124b 100644 --- a/src/state/CallViewModel/localMember/LocalTransport.ts +++ b/src/state/CallViewModel/localMember/LocalTransport.ts @@ -27,7 +27,10 @@ import { AutoDiscovery } from "matrix-js-sdk/lib/autodiscovery"; import { type Behavior } from "../../Behavior.ts"; import { type Epoch, type ObservableScope } from "../../ObservableScope.ts"; import { Config } from "../../../config/Config.ts"; -import { MatrixRTCTransportMissingError } from "../../../utils/errors.ts"; +import { + FailToGetOpenIdToken, + MatrixRTCTransportMissingError, +} from "../../../utils/errors.ts"; import { getSFUConfigWithOpenID, type OpenIDClientParts, @@ -169,6 +172,10 @@ async function makeTransport( livekit_alias: livekitAlias, }; } catch (ex) { + if (ex instanceof FailToGetOpenIdToken) { + // Explictly throw these + throw ex; + } logger.debug( `Could not use SFU service "${potentialTransport.livekit_service_url}" as SFU`, ex, @@ -193,6 +200,8 @@ async function makeTransport( if (ex instanceof MatrixError && ex.httpStatus === 404) { // Expected, this is an unstable endpoint and it's not required. logger.debug("Backend does not provide any RTC transports", ex); + } else if (ex instanceof FailToGetOpenIdToken) { + throw ex; } else { // We got an error that wasn't just missing support for the feature, so log it loudly. logger.error( @@ -233,6 +242,9 @@ async function makeTransport( logger.info("Using config SFU", selectedTransport); return selectedTransport; } catch (ex) { + if (ex instanceof FailToGetOpenIdToken) { + throw ex; + } logger.error("Failed to validate config SFU", ex); } }