Merge deadlines for downloads
All checks were successful
build-and-push / docker (push) Successful in 39s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
dlawler489 2026-09-16 17:52:12 +10:00
commit b2078690bd
2 changed files with 8 additions and 3 deletions

View file

@ -21,6 +21,9 @@ async function solve(flaresolverrUrl, targetUrl, opts = {}) {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
// FlareSolverr is told to give up at maxTimeout; if it doesn't answer
// even then, stop waiting rather than hanging the request for ever.
signal: AbortSignal.timeout((opts.maxTimeout || 60000) + 15000),
});
if (res.status >= 500) { lastErr = new Error(`FlareSolverr HTTP ${res.status}`); continue; }
if (!res.ok) throw new Error(`FlareSolverr HTTP ${res.status}`);
@ -29,7 +32,7 @@ async function solve(flaresolverrUrl, targetUrl, opts = {}) {
return data.solution.response;
} catch (err) {
lastErr = err;
if (!/HTTP 5\d\d|fetch failed|ECONNRESET|network/i.test(err.message)) throw err;
if (!/HTTP 5\d\d|fetch failed|ECONNRESET|network|timeout|aborted/i.test(err.message)) throw err;
}
}
throw lastErr;

View file

@ -993,7 +993,8 @@ async function downloadMakerworldFiles(html, skipNames = new Set()) {
}
const original = dl.name || `instance-${inst.id}.3mf`;
if (skipNames.has(original)) continue;
const resp = await fetch(dl.url);
// A stalled CDN connection would otherwise hang the download for ever.
const resp = await fetch(dl.url, { signal: AbortSignal.timeout(180000) });
if (!resp.ok) {
console.warn(`MakerWorld CDN download ${resp.status} for ${original}`);
problems.push({ message: `Downloading ${original} from MakerWorld failed (HTTP ${resp.status})` });
@ -1064,7 +1065,8 @@ async function downloadThingiverseFiles(meta, skipNames = new Set()) {
for (const dl of meta.downloads) {
if (!fileProcessor.isAllowed(dl.name)) continue; // skip readmes/images
if (skipNames.has(dl.name)) continue;
const resp = await fetch(dl.url);
// A stalled CDN connection would otherwise hang the download for ever.
const resp = await fetch(dl.url, { signal: AbortSignal.timeout(180000) });
if (!resp.ok) { console.error(`Download failed (${resp.status}): ${dl.name}`); continue; }
const buffer = Buffer.from(await resp.arrayBuffer());
const fileName = uniqueName(dl.name);