Skip to content

Commit eb69021

Browse files
authored
Refactor(retry-plugin): unify retry behavior and improve resilience (#4043)
1 parent c3ef0fe commit eb69021

File tree

15 files changed

+1966
-991
lines changed

15 files changed

+1966
-991
lines changed

.changeset/beige-meals-wash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@module-federation/retry-plugin': minor
3+
'website-new': minor
4+
---
5+
6+
Refactor(retry-plugin): unify retry behavior and improve resilience

apps/router-demo/router-host-2000/src/App.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import React, {
55
Suspense,
66
} from 'react';
77
import { Route, Routes, useLocation } from 'react-router-dom';
8-
import { init, loadRemote } from '@module-federation/enhanced/runtime';
8+
import {
9+
loadRemote,
10+
createInstance,
11+
} from '@module-federation/enhanced/runtime';
912
import { RetryPlugin } from '@module-federation/retry-plugin';
1013
import { createRemoteAppComponent } from '@module-federation/bridge-react';
1114
import Navigation from './navigation';
@@ -17,7 +20,6 @@ import { ErrorBoundary } from 'react-error-boundary';
1720
import Remote1AppNew from 'remote1/app';
1821
import type { ModuleFederationRuntimePlugin } from '@module-federation/enhanced/runtime';
1922
import { Spin } from 'antd';
20-
import { createInstance } from '@module-federation/enhanced/runtime';
2123

2224
const fallbackPlugin: () => ModuleFederationRuntimePlugin = function () {
2325
return {

apps/router-demo/router-host-2000/src/runtime-plugin/retry.ts

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,26 @@ import { RetryPlugin } from '@module-federation/retry-plugin';
22

33
const retryPlugin = () =>
44
RetryPlugin({
5-
fetch: {
6-
// fallback: () => 'http://localhost:2001/mf-manifest.json',
7-
// getRetryPath: (url) => {
8-
// return 'http://localhost:2001/mf-manifest.json?test=1';
9-
// },
5+
retryTimes: 3,
6+
retryDelay: 1000,
7+
onRetry: (params) => {
8+
console.log('onRetry', params);
109
},
11-
script: {
12-
retryTimes: 3,
13-
retryDelay: 1000,
14-
// moduleName: ['remote1'],
15-
cb: (resolve, error) => {
16-
if (error) {
17-
throw new Error(
18-
'The request failed three times and has now been abandoned',
19-
);
20-
}
21-
return setTimeout(() => {
22-
resolve(error);
23-
}, 1000);
24-
},
25-
getRetryPath: (url) => {
26-
return 'http://localhost:2001/remote1.js?test=2';
27-
},
10+
onSuccess: (params) => {
11+
console.log('onSuccess', params);
12+
},
13+
onError: (params) => {
14+
console.log('onError', params);
15+
},
16+
manifestDomains: ['https://m1.example.com', 'https://m2.example.com'],
17+
domains: [
18+
'http://localhost:2011',
19+
'http://localhost:2021',
20+
'http://localhost:2031',
21+
],
22+
addQuery: true,
23+
fetchOptions: {
24+
method: 'GET',
2825
},
2926
});
3027
export default retryPlugin;

0 commit comments

Comments
 (0)