mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-06-09 11:30:42 +00:00
fix: add timeout to fetch to prevent silent hangs (#883)
Add `AbortSignal.timeout(5s)` to fetch requests to ensure they fail fast instead of hanging indefinitely when network issues occur.
This commit is contained in:
12
dist/setup/index.cjs
generated
vendored
12
dist/setup/index.cjs
generated
vendored
@@ -95790,10 +95790,16 @@ function getProxyAgent() {
|
|||||||
}
|
}
|
||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
var fetch = async (url2, opts) => await (0, import_undici2.fetch)(url2, {
|
var fetch = async (url2, opts) => {
|
||||||
|
const timeoutSignal = AbortSignal.timeout(5e3);
|
||||||
|
const existingSignal = opts.signal;
|
||||||
|
const mergedSignal = existingSignal ? AbortSignal.any([timeoutSignal, existingSignal]) : timeoutSignal;
|
||||||
|
return await (0, import_undici2.fetch)(url2, {
|
||||||
dispatcher: getProxyAgent(),
|
dispatcher: getProxyAgent(),
|
||||||
...opts
|
...opts,
|
||||||
});
|
signal: mergedSignal
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// src/download/variant-selection.ts
|
// src/download/variant-selection.ts
|
||||||
function selectDefaultVariant(entries, duplicateEntryDescription) {
|
function selectDefaultVariant(entries, duplicateEntryDescription) {
|
||||||
|
|||||||
12
dist/update-known-checksums/index.cjs
generated
vendored
12
dist/update-known-checksums/index.cjs
generated
vendored
@@ -49749,10 +49749,16 @@ function getProxyAgent() {
|
|||||||
}
|
}
|
||||||
return void 0;
|
return void 0;
|
||||||
}
|
}
|
||||||
var fetch = async (url, opts) => await (0, import_undici2.fetch)(url, {
|
var fetch = async (url, opts) => {
|
||||||
|
const timeoutSignal = AbortSignal.timeout(5e3);
|
||||||
|
const existingSignal = opts.signal;
|
||||||
|
const mergedSignal = existingSignal ? AbortSignal.any([timeoutSignal, existingSignal]) : timeoutSignal;
|
||||||
|
return await (0, import_undici2.fetch)(url, {
|
||||||
dispatcher: getProxyAgent(),
|
dispatcher: getProxyAgent(),
|
||||||
...opts
|
...opts,
|
||||||
});
|
signal: mergedSignal
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// src/download/manifest.ts
|
// src/download/manifest.ts
|
||||||
var cachedManifestData = /* @__PURE__ */ new Map();
|
var cachedManifestData = /* @__PURE__ */ new Map();
|
||||||
|
|||||||
@@ -14,8 +14,17 @@ export function getProxyAgent() {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetch = async (url: string, opts: RequestInit) =>
|
export const fetch = async (url: string, opts: RequestInit) => {
|
||||||
await undiciFetch(url, {
|
// Merge timeout signal with any existing signal from opts
|
||||||
|
const timeoutSignal = AbortSignal.timeout(5_000);
|
||||||
|
const existingSignal = opts.signal;
|
||||||
|
const mergedSignal = existingSignal
|
||||||
|
? AbortSignal.any([timeoutSignal, existingSignal])
|
||||||
|
: timeoutSignal;
|
||||||
|
|
||||||
|
return await undiciFetch(url, {
|
||||||
dispatcher: getProxyAgent(),
|
dispatcher: getProxyAgent(),
|
||||||
...opts,
|
...opts,
|
||||||
|
signal: mergedSignal,
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user