ソースを参照

Chore: log failed URL

SukkaW 1 年間 前
コミット
9354cf1d28
1 ファイル変更5 行追加1 行削除
  1. 5 1
      Build/lib/fetch-retry.ts

+ 5 - 1
Build/lib/fetch-retry.ts

@@ -42,6 +42,10 @@ setGlobalDispatcher(agent.compose(
     retry(err, { state, opts }, cb) {
     retry(err, { state, opts }, cb) {
       const errorCode = 'code' in err ? (err as NodeJS.ErrnoException).code : undefined;
       const errorCode = 'code' in err ? (err as NodeJS.ErrnoException).code : undefined;
 
 
+      Object.defineProperty(err, '_url', {
+        value: opts.method + ' ' + opts.origin?.toString() + opts.path
+      });
+
       // Any code that is not a Undici's originated and allowed to retry
       // Any code that is not a Undici's originated and allowed to retry
       if (
       if (
         errorCode === 'ERR_UNESCAPED_CHARACTERS'
         errorCode === 'ERR_UNESCAPED_CHARACTERS'
@@ -151,7 +155,7 @@ export const defaultRequestInit = {
   }
   }
 };
 };
 
 
-export async function $$fetch(url: string, init?: RequestInit) {
+export async function $$fetch(url: string, init: RequestInit = defaultRequestInit) {
   try {
   try {
     const res = await undici.fetch(url, init);
     const res = await undici.fetch(url, init);
     if (res.status >= 400) {
     if (res.status >= 400) {