mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-10 21:55:19 +00:00
Make delegation support check fail immediately in case of CORS errors
This commit is contained in:
@@ -75,7 +75,6 @@ import {
|
|||||||
import { type HomeserverConnected } from "./HomeserverConnected.ts";
|
import { type HomeserverConnected } from "./HomeserverConnected.ts";
|
||||||
import { type LocalTransport } from "./LocalTransport.ts";
|
import { type LocalTransport } from "./LocalTransport.ts";
|
||||||
import { areLivekitTransportsEqual } from "../remoteMembers/MatrixLivekitMembers.ts";
|
import { areLivekitTransportsEqual } from "../remoteMembers/MatrixLivekitMembers.ts";
|
||||||
import { doNetworkOperationWithRetry } from "../../../utils/matrix.ts";
|
|
||||||
import { or$ } from "../../../utils/observable.ts";
|
import { or$ } from "../../../utils/observable.ts";
|
||||||
|
|
||||||
export enum TransportState {
|
export enum TransportState {
|
||||||
@@ -253,10 +252,12 @@ export const createLocalMembership$ = ({
|
|||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
logger.info(`Checking whether ${serviceName} supports delegation…`);
|
logger.info(`Checking whether ${serviceName} supports delegation…`);
|
||||||
try {
|
try {
|
||||||
// Bluntly hit the endpoint without auth to check for a 404
|
// Bluntly hit the endpoint without auth to check for a 404. Unfortunately
|
||||||
const res = await doNetworkOperationWithRetry(async () =>
|
// we can't wrap this in a retry loop, as many servers don't just disable
|
||||||
fetch(endpointUrl, { method: "POST" }),
|
// 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) {
|
if (res.status === 404) {
|
||||||
logger.warn(`${serviceName} does not support delegation`);
|
logger.warn(`${serviceName} does not support delegation`);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user