From 9354cf1d289e825cecc6c94adc5c132ca36bc3b2 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sat, 8 Feb 2025 22:26:06 +0800 Subject: [PATCH] Chore: log failed URL --- Build/lib/fetch-retry.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Build/lib/fetch-retry.ts b/Build/lib/fetch-retry.ts index e7b109fc..0138ae42 100644 --- a/Build/lib/fetch-retry.ts +++ b/Build/lib/fetch-retry.ts @@ -42,6 +42,10 @@ setGlobalDispatcher(agent.compose( retry(err, { state, opts }, cb) { 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 if ( 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 { const res = await undici.fetch(url, init); if (res.status >= 400) {