Selaa lähdekoodia

fix: fetchAdvanced timeout abort on error

Sv443 9 kuukautta sitten
vanhempi
commit
4cb3ce724e
1 muutettua tiedostoa jossa 12 lisäystä ja 7 poistoa
  1. 12 7
      lib/misc.ts

+ 12 - 7
lib/misc.ts

@@ -73,13 +73,18 @@ export async function fetchAdvanced(input: RequestInfo | URL, options: FetchAdva
     signalOpts = { signal: controller.signal };
   }
 
-  const res = await fetch(input, {
-    ...options,
-    ...signalOpts,
-  });
-
-  clearTimeout(id);
-  return res;
+  try {
+    const res = await fetch(input, {
+      ...options,
+      ...signalOpts,
+    });
+    id && clearTimeout(id);
+    return res;
+  }
+  catch(err) {
+    id && clearTimeout(id);
+    throw err;
+  }
 }
 
 /**