@fudrouter/fsrouter 0.6.112 → 0.6.113
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.
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
// Fetch with timeout wrapper
|
|
1
|
+
// Fetch with timeout wrapper — uses AbortSignal.timeout (reliably aborts the
|
|
2
|
+
// underlying request instead of just racing a dangling promise that can hang
|
|
3
|
+
// the whole HTTP handler / make the browser show "Network error").
|
|
2
4
|
const fetchWithTimeout = (url, options, timeout = 10000) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
]);
|
|
5
|
+
const controller = new AbortController();
|
|
6
|
+
const t = setTimeout(() => controller.abort(), timeout);
|
|
7
|
+
return fetch(url, { ...options, signal: controller.signal }).finally(() => clearTimeout(t));
|
|
7
8
|
};
|
|
8
9
|
// Validate URL format
|
|
9
10
|
const isValidUrl = (url) => {
|