mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 19:56:47 +03:00
Add an overall reachability timeout of 10s
This adds a reachability timeout of 10s when checking the IS for 3PID bindings. This ensures we stop in a reasonable time, rather than waiting for a long list of requests to eventually timeout via some general mechanism. Part of https://github.com/vector-im/riot-web/issues/10909
This commit is contained in:
parent
e6a81c5733
commit
579ada3ca2
1 changed files with 11 additions and 2 deletions
|
@ -28,6 +28,9 @@ import {SERVICE_TYPES} from "matrix-js-sdk";
|
||||||
import {abbreviateUrl, unabbreviateUrl} from "../../../utils/UrlUtils";
|
import {abbreviateUrl, unabbreviateUrl} from "../../../utils/UrlUtils";
|
||||||
import { getDefaultIdentityServerUrl } from '../../../utils/IdentityServerUtils';
|
import { getDefaultIdentityServerUrl } from '../../../utils/IdentityServerUtils';
|
||||||
|
|
||||||
|
// We'll wait up to this long when checking for 3PID bindings on the IS.
|
||||||
|
const REACHABILITY_TIMEOUT = 10000; // ms
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check an IS URL is valid, including liveness check
|
* Check an IS URL is valid, including liveness check
|
||||||
*
|
*
|
||||||
|
@ -254,7 +257,14 @@ export default class SetIdServer extends React.Component {
|
||||||
let threepids = [];
|
let threepids = [];
|
||||||
let currentServerReachable = true;
|
let currentServerReachable = true;
|
||||||
try {
|
try {
|
||||||
threepids = await getThreepidsWithBindStatus(MatrixClientPeg.get());
|
threepids = await Promise.race([
|
||||||
|
getThreepidsWithBindStatus(MatrixClientPeg.get()),
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
reject(new Error("Timeout attempting to reach identity server"));
|
||||||
|
}, REACHABILITY_TIMEOUT);
|
||||||
|
}),
|
||||||
|
]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
currentServerReachable = false;
|
currentServerReachable = false;
|
||||||
console.warn(
|
console.warn(
|
||||||
|
@ -263,7 +273,6 @@ export default class SetIdServer extends React.Component {
|
||||||
);
|
);
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
const boundThreepids = threepids.filter(tp => tp.bound);
|
const boundThreepids = threepids.filter(tp => tp.bound);
|
||||||
let message;
|
let message;
|
||||||
let danger = false;
|
let danger = false;
|
||||||
|
|
Loading…
Reference in a new issue