From 839e36abd41c3d8ab2cf6d784c7d1f55307a5f2a Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 8 Sep 2026 21:21:36 +0200 Subject: [PATCH] Make delegation support check fail immediately in case of CORS errors --- src/state/CallViewModel/localMember/LocalMember.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/state/CallViewModel/localMember/LocalMember.ts b/src/state/CallViewModel/localMember/LocalMember.ts index 838b14ee2..fc5e65cf2 100644 --- a/src/state/CallViewModel/localMember/LocalMember.ts +++ b/src/state/CallViewModel/localMember/LocalMember.ts @@ -75,7 +75,6 @@ import { import { type HomeserverConnected } from "./HomeserverConnected.ts"; import { type LocalTransport } from "./LocalTransport.ts"; import { areLivekitTransportsEqual } from "../remoteMembers/MatrixLivekitMembers.ts"; -import { doNetworkOperationWithRetry } from "../../../utils/matrix.ts"; import { or$ } from "../../../utils/observable.ts"; export enum TransportState { @@ -253,10 +252,12 @@ export const createLocalMembership$ = ({ ): Promise { logger.info(`Checking whether ${serviceName} supports delegation…`); try { - // Bluntly hit the endpoint without auth to check for a 404 - const res = await doNetworkOperationWithRetry(async () => - fetch(endpointUrl, { method: "POST" }), - ); + // Bluntly hit the endpoint without auth to check for a 404. Unfortunately + // we can't wrap this in a retry loop, as many servers don't just disable + // delegation support, but in fact are from a time before the endpoint + // existed at all, therefore we can hit CORS errors which would just gum + // up the retry loop. (May be revisited after Matrix 2.0.) + const res = await fetch(endpointUrl, { method: "POST" }); if (res.status === 404) { logger.warn(`${serviceName} does not support delegation`); return false;