Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit ad8543e

Browse files
authored
Increase RTE resilience (#11111)
* add retry logic to the dynamic import for the composers * add retry to the conversion function too * add retry to final function * add comment
1 parent a4cf2af commit ad8543e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/components/views/rooms/wysiwyg_composer/DynamicImportWysiwygComposer.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,20 @@ import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
2020
// we need to import the types for TS, but do not import the sendMessage
2121
// function to avoid importing from "@matrix-org/matrix-wysiwyg"
2222
import { SendMessageParams } from "./utils/message";
23+
import { retry } from "../../../../utils/promise";
2324

24-
const SendComposer = lazy(() => import("./SendWysiwygComposer"));
25-
const EditComposer = lazy(() => import("./EditWysiwygComposer"));
25+
// Due to issues such as https://github.com/vector-im/element-web/issues/25277, we add retry
26+
// attempts to all of the dynamic imports in this file
27+
const RETRY_COUNT = 3;
28+
const SendComposer = lazy(() => retry(() => import("./SendWysiwygComposer"), RETRY_COUNT));
29+
const EditComposer = lazy(() => retry(() => import("./EditWysiwygComposer"), RETRY_COUNT));
2630

2731
export const dynamicImportSendMessage = async (
2832
message: string,
2933
isHTML: boolean,
3034
params: SendMessageParams,
3135
): Promise<ISendEventResponse | undefined> => {
32-
const { sendMessage } = await import("./utils/message");
36+
const { sendMessage } = await retry(() => import("./utils/message"), RETRY_COUNT);
3337

3438
return sendMessage(message, isHTML, params);
3539
};
@@ -38,7 +42,7 @@ export const dynamicImportConversionFunctions = async (): Promise<{
3842
richToPlain(rich: string): Promise<string>;
3943
plainToRich(plain: string): Promise<string>;
4044
}> => {
41-
const { richToPlain, plainToRich } = await import("@matrix-org/matrix-wysiwyg");
45+
const { richToPlain, plainToRich } = await retry(() => import("@matrix-org/matrix-wysiwyg"), RETRY_COUNT);
4246

4347
return { richToPlain, plainToRich };
4448
};

src/components/views/rooms/wysiwyg_composer/SendWysiwygComposer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Content = forwardRef<HTMLElement, ContentProps>(function Content(
4040
return null;
4141
});
4242

43-
interface SendWysiwygComposerProps {
43+
export interface SendWysiwygComposerProps {
4444
initialContent?: string;
4545
isRichTextEnabled: boolean;
4646
placeholder?: string;

0 commit comments

Comments
 (0)