@hot-updater/protocol 1.0.0-rc.28 → 1.0.0-rc.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -2
- package/dist/index.mjs +6 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -199,7 +199,11 @@ const createPluginHost = (environment) => {
|
|
|
199
199
|
const abortFromCaller = () => controller.abort();
|
|
200
200
|
if (callerSignal?.aborted) controller.abort();
|
|
201
201
|
callerSignal?.addEventListener("abort", abortFromCaller);
|
|
202
|
-
|
|
202
|
+
let timedOut = false;
|
|
203
|
+
const timeoutId = setTimeout(() => {
|
|
204
|
+
timedOut = true;
|
|
205
|
+
controller.abort();
|
|
206
|
+
}, requestTimeout ?? 5e3);
|
|
203
207
|
try {
|
|
204
208
|
return await environment.fetch(url, {
|
|
205
209
|
...init,
|
|
@@ -207,7 +211,7 @@ const createPluginHost = (environment) => {
|
|
|
207
211
|
signal: controller.signal
|
|
208
212
|
});
|
|
209
213
|
} catch (error) {
|
|
210
|
-
if (error instanceof Error && error.name === "AbortError"
|
|
214
|
+
if (!callerSignal?.aborted && (timedOut || error instanceof Error && error.name === "AbortError")) throw new Error("Request timed out");
|
|
211
215
|
throw error;
|
|
212
216
|
} finally {
|
|
213
217
|
clearTimeout(timeoutId);
|
package/dist/index.mjs
CHANGED
|
@@ -198,7 +198,11 @@ const createPluginHost = (environment) => {
|
|
|
198
198
|
const abortFromCaller = () => controller.abort();
|
|
199
199
|
if (callerSignal?.aborted) controller.abort();
|
|
200
200
|
callerSignal?.addEventListener("abort", abortFromCaller);
|
|
201
|
-
|
|
201
|
+
let timedOut = false;
|
|
202
|
+
const timeoutId = setTimeout(() => {
|
|
203
|
+
timedOut = true;
|
|
204
|
+
controller.abort();
|
|
205
|
+
}, requestTimeout ?? 5e3);
|
|
202
206
|
try {
|
|
203
207
|
return await environment.fetch(url, {
|
|
204
208
|
...init,
|
|
@@ -206,7 +210,7 @@ const createPluginHost = (environment) => {
|
|
|
206
210
|
signal: controller.signal
|
|
207
211
|
});
|
|
208
212
|
} catch (error) {
|
|
209
|
-
if (error instanceof Error && error.name === "AbortError"
|
|
213
|
+
if (!callerSignal?.aborted && (timedOut || error instanceof Error && error.name === "AbortError")) throw new Error("Request timed out");
|
|
210
214
|
throw error;
|
|
211
215
|
} finally {
|
|
212
216
|
clearTimeout(timeoutId);
|