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

Increase RTE resilience #11111

Merged
merged 7 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@ import { ISendEventResponse } from "matrix-js-sdk/src/@types/requests";
// we need to import the types for TS, but do not import the sendMessage
// function to avoid importing from "@matrix-org/matrix-wysiwyg"
import { SendMessageParams } from "./utils/message";
import { retry } from "../../../../utils/promise";

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

export const dynamicImportSendMessage = async (
message: string,
isHTML: boolean,
params: SendMessageParams,
): Promise<ISendEventResponse | undefined> => {
const { sendMessage } = await import("./utils/message");
const { sendMessage } = await retry(() => import("./utils/message"), RETRY_COUNT);

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

return { richToPlain, plainToRich };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Content = forwardRef<HTMLElement, ContentProps>(function Content(
return null;
});

interface SendWysiwygComposerProps {
export interface SendWysiwygComposerProps {
initialContent?: string;
isRichTextEnabled: boolean;
placeholder?: string;
Expand Down