You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resource retry plugin is used to retry resources when they fail to load, thereby increasing the success rate of resource loading. In Module Federation, we provide the retry plugin `RetryPlugin` to increase the retry mechanism, which can improve the stability of the application.
5
+
resource retry plugin is used to retry resources when they fail to load, thereby increasing the success rate of resource loading. In Module Federation, we provide the retry plugin `RetryPlugin` to increase the retry mechanism for remote applications, which can improve the stability of the application.
8
6
9
7
## Installation
10
-
11
-
This `RetryPlugin` is Provided by the `@module-federation/retry-plugin` package
8
+
resource retry plugin is provided by the `@module-federation/retry-plugin` package. Let's install it first.
12
9
13
10
<PackageManagerTabs
14
11
command={{
@@ -21,16 +18,19 @@ This `RetryPlugin` is Provided by the `@module-federation/retry-plugin` package
21
18
22
19
## Usage
23
20
24
-
`RetryPlugin` is a runtime plugin, we can register this plugin through the `runtimePlugin` of the build plugin or register it at runtime and configure retry parameters and retry logic, etc.:
25
-
21
+
`RetryPlugin` is a runtime plugin, and we can register this plugin through the `runtimePlugin` of the build plugin or register it at runtime and configure retry parameters and retry logic, etc.:
26
22
27
23
:::note
28
-
Note: Choose either of the two ways to register the build plugin and do not register it repeatedly
24
+
25
+
Attention
26
+
27
+
- build plugin registration and runtime registration are optional. You can choose either one, but not both.
28
+
- It is recommended to register the RetryPlugin as early as possible in the build plugin to avoid the failure of resource requests, which may cause the project to fail to start and cannot enter the runtime to register the retry plugin, thus failing to retry resources.
29
29
30
30
:::
31
31
32
32
33
-
### Method1: Register in the build plugin
33
+
### The first way: register in the build plugin
34
34
35
35
```diff
36
36
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';
the resource that needs to be retried is divided into two types: the `fetch` type and the `script` type, and we control the retry logic of these two resource types through the `fetch` parameter and the `script` parameter, respectively.
82
+
the resources that need to be retried are divided into two types: fetch type and script type. We control the retry logic of these two resource types respectively through the `fetch` parameter and the `script` parameter.
111
83
112
84
## Type
113
85
@@ -128,87 +100,107 @@ type FetchWithRetryOptions = {
`RetryPluginParams` is the parameter type used to configure `RetryPlugin`, which contains retry options for two types of resources: `fetch` and `script`.
113
+
`RetryPluginParams` is the parameter type used to configure the `RetryPlugin`, which contains retry options for two types of resources: `fetch` and `script`.
143
114
144
115
### Properties
145
116
146
-
-**fetch**: `FetchWithRetryOptions` (optional)
147
-
- Used to configure the retry options for fetch type resources.
148
-
149
117
-**script**: `ScriptWithRetryOptions` (optional)
150
-
-Used to configure the retry options for script type resources.
118
+
-used to configure the retry options for fetch type resources.
151
119
120
+
-**script**: `ScriptWithRetryOptions` (optional)
121
+
-`ScriptWithRetryOptions` is the type used to configure the retry options for script type resources.
152
122
153
-
## FetchWithRetryOptions type description
154
-
155
-
`FetchWithRetryOptions` is the type used to configure the retry options for fetch type resources.
156
-
157
-
### 属性
158
-
### Properties
123
+
### FetchWithRetryOptions Type Description
159
124
160
125
-**url**:
161
126
-`string`
162
-
-Optional. When not set, all failed resources will default to retry logic.
163
-
- The URL of the resource to be retried.
127
+
-optional, when not set, all failed URLs will enter the retry logic by default
128
+
- The URL of the resource that needs to be retried.
164
129
165
130
-**options**:
166
131
-`RequestInit`
167
-
-Optional.
168
-
-The request options for the fetch request.
132
+
-optional
133
+
-Options passed to the fetch request.
169
134
170
135
-**retryTimes**:
171
136
-`number`
172
-
-Optional.
173
-
- The number of retry attempts. Defaults to 3.
137
+
-Options
138
+
- The number of retries, default is 3.
174
139
175
140
-**retryDelay**:
176
141
-`number`
177
-
-Optional.
178
-
- The delay between retry attempts in milliseconds. Defaults to 1000.
142
+
-optional
143
+
- The delay time between each retry (in milliseconds).
179
144
180
145
-**fallback**:
181
146
-`() => string`
182
-
-Optional. A function that returns a Promise that resolves to a Response object. This function is called when all retry attempts have failed.
183
-
147
+
-optional
148
+
- Returns the URL of a backup resource after all retries fail.
184
149
185
-
### ScriptWithRetryOptions Type Description
150
+
### ScriptWithRetryOptions 类型说明
186
151
187
-
`ScriptWithRetryOptions` is the type used to configure the retry options for script type resources.
152
+
-**retryTimes**:
153
+
-`number`
154
+
- optional
155
+
- The number of retries, default is 3.
188
156
189
-
### Properties
157
+
-**retryDelay**:
158
+
-`number`
159
+
- optional
160
+
- The delay time between each retry (in milliseconds).
190
161
191
-
-**url**:
162
+
-**moduleName**:
192
163
-`string`
193
-
-Optional. When not set, all failed resources will default to retry logic.
194
-
- The URL of the resource to be retried.
164
+
-optional
165
+
- The module name, used to identify the module that needs to be retried.
195
166
196
-
-**attrs**:
197
-
-`Record<string, string>`
198
-
-Optional
199
-
-The attributes to be passed to the script element.
0 commit comments