1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-31 13:44:28 +03:00

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:
David Baker
2024-02-26 15:30:32 +00:00
committed by GitHub
parent f2101c69ec
commit 1403cd851a
4 changed files with 145 additions and 44 deletions

View File

@ -28,7 +28,6 @@ import { MatrixClientPeg } from "../src/MatrixClientPeg";
import Modal from "../src/Modal";
import * as StorageManager from "../src/utils/StorageManager";
import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser, mockPlatformPeg } from "./test-utils";
import ToastStore from "../src/stores/ToastStore";
import { OidcClientStore } from "../src/stores/oidc/OidcClientStore";
import { makeDelegatedAuthConfig } from "./test-utils/oidc";
import { persistOidcAuthenticatedSettings } from "../src/utils/oidc/persistOidcSettings";
@ -452,17 +451,10 @@ describe("Lifecycle", () => {
});
});
it("should show a toast if the matrix server version is unsupported", async () => {
const toastSpy = jest.spyOn(ToastStore.sharedInstance(), "addOrReplaceToast");
mockClient.isVersionSupported.mockImplementation(async (version) => version == "r0.6.0");
initLocalStorageMock({ ...localStorageSession });
it("should proceed if server is not accessible", async () => {
mockClient.isVersionSupported.mockRejectedValue(new Error("Oh, noes, the server is down!"));
expect(await restoreFromLocalStorage()).toEqual(true);
expect(toastSpy).toHaveBeenCalledWith(
expect.objectContaining({
title: "Your server is unsupported",
}),
);
});
});
});