浏览代码

Chore: adjust mirror url sleep before fetch

SukkaW 1 年之前
父节点
当前提交
a0cadecfb9
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      Build/lib/cache-filesystem.ts
  2. 2 2
      Build/lib/fetch-assets.ts

+ 2 - 2
Build/lib/cache-filesystem.ts

@@ -291,9 +291,9 @@ export class Cache<S = string> {
 
     const createFetchFallbackPromise = async (url: string, index: number) => {
       // Most assets can be downloaded within 250ms. To avoid wasting bandwidth, we will wait for 500ms before downloading from the fallback URL.
-      if (index > 0) {
+      if (index >= 0) {
         try {
-          await sleepWithAbort(100 + (index + 1) * 10, controller.signal);
+          await sleepWithAbort(50 + (index + 1) * 100, controller.signal);
         } catch {
           console.log(picocolors.gray('[fetch cancelled early]'), picocolors.gray(url));
           throw new CustomAbortError();

+ 2 - 2
Build/lib/fetch-assets.ts

@@ -45,10 +45,10 @@ export async function fetchAssetsWithout304(url: string, fallbackUrls: string[]
   const controller = new AbortController();
 
   const createFetchFallbackPromise = async (url: string, index: number) => {
-    if (index > 0) {
+    if (index >= 0) {
     // Most assets can be downloaded within 250ms. To avoid wasting bandwidth, we will wait for 500ms before downloading from the fallback URL.
       try {
-        await sleepWithAbort(500 + (index + 1) * 10, controller.signal);
+        await sleepWithAbort(50 + (index + 1) * 100, controller.signal);
       } catch {
         console.log(picocolors.gray('[fetch cancelled early]'), picocolors.gray(url));
         throw new CustomAbortError();