@@ -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"
2222import { 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
2731export 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} ;
0 commit comments