Fix spurious session corruption error (#12280)
* Fix spurious session corruption error Move the server versions check to each time we reconnect to the server rather than the first time,although, as per comment it will still only trigger the first time, but it will avoid us awaiting and mean we know we're connected to the server when we try, and get automatic retries. Fixes https://github.com/element-hq/element-web/issues/26967 * Move test & add regression test * Write some more tests * More comments & catch exceptions in server versions check * Note caching behaviour * Typo Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Remove the bit of the comment that might be wrong --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
parent
f2101c69ec
commit
1403cd851a
4 changed files with 145 additions and 44 deletions
|
@ -23,7 +23,6 @@ import { InvalidStoreError } from "matrix-js-sdk/src/errors";
|
|||
import { IEncryptedPayload } from "matrix-js-sdk/src/crypto/aes";
|
||||
import { QueryDict } from "matrix-js-sdk/src/utils";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { MINIMUM_MATRIX_VERSION, SUPPORTED_MATRIX_VERSIONS } from "matrix-js-sdk/src/version-support";
|
||||
|
||||
import { IMatrixClientCreds, MatrixClientPeg } from "./MatrixClientPeg";
|
||||
import SecurityCustomisations from "./customisations/Security";
|
||||
|
@ -74,7 +73,6 @@ import {
|
|||
getStoredOidcTokenIssuer,
|
||||
persistOidcAuthenticatedSettings,
|
||||
} from "./utils/oidc/persistOidcSettings";
|
||||
import GenericToast from "./components/views/toasts/GenericToast";
|
||||
import {
|
||||
ACCESS_TOKEN_IV,
|
||||
ACCESS_TOKEN_STORAGE_KEY,
|
||||
|
@ -647,7 +645,6 @@ export async function restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }):
|
|||
},
|
||||
false,
|
||||
);
|
||||
await checkServerVersions();
|
||||
return true;
|
||||
} else {
|
||||
logger.log("No previous session found.");
|
||||
|
@ -655,37 +652,6 @@ export async function restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }):
|
|||
}
|
||||
}
|
||||
|
||||
async function checkServerVersions(): Promise<void> {
|
||||
const client = MatrixClientPeg.get();
|
||||
if (!client) return;
|
||||
for (const version of SUPPORTED_MATRIX_VERSIONS) {
|
||||
// Check if the server supports this spec version. (`isVersionSupported` caches the response, so this loop will
|
||||
// only make a single HTTP request).
|
||||
if (await client.isVersionSupported(version)) {
|
||||
// we found a compatible spec version
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const toastKey = "LEGACY_SERVER";
|
||||
ToastStore.sharedInstance().addOrReplaceToast({
|
||||
key: toastKey,
|
||||
title: _t("unsupported_server_title"),
|
||||
props: {
|
||||
description: _t("unsupported_server_description", {
|
||||
version: MINIMUM_MATRIX_VERSION,
|
||||
brand: SdkConfig.get().brand,
|
||||
}),
|
||||
acceptLabel: _t("action|ok"),
|
||||
onAccept: () => {
|
||||
ToastStore.sharedInstance().dismissToast(toastKey);
|
||||
},
|
||||
},
|
||||
component: GenericToast,
|
||||
priority: 98,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleLoadSessionFailure(e: unknown): Promise<boolean> {
|
||||
logger.error("Unable to load session", e);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue