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 commentpull/28788/head^2
parent
a4cf2af187
commit
ad8543eb58
|
@ -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);
|
||||
};
|
||||
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ const Content = forwardRef<HTMLElement, ContentProps>(function Content(
|
|||
return null;
|
||||
});
|
||||
|
||||
interface SendWysiwygComposerProps {
|
||||
export interface SendWysiwygComposerProps {
|
||||
initialContent?: string;
|
||||
isRichTextEnabled: boolean;
|
||||
placeholder?: string;
|
||||
|
|
Loading…
Reference in New Issue