mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Chore: log failed URL
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user