Compare commits
2 commits
27e1caf1a6
...
b2078690bd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2078690bd | ||
|
|
341731a946 |
2 changed files with 8 additions and 3 deletions
|
|
@ -21,6 +21,9 @@ async function solve(flaresolverrUrl, targetUrl, opts = {}) {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify(body),
|
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.status >= 500) { lastErr = new Error(`FlareSolverr HTTP ${res.status}`); continue; }
|
||||||
if (!res.ok) throw new Error(`FlareSolverr HTTP ${res.status}`);
|
if (!res.ok) throw new Error(`FlareSolverr HTTP ${res.status}`);
|
||||||
|
|
@ -29,7 +32,7 @@ async function solve(flaresolverrUrl, targetUrl, opts = {}) {
|
||||||
return data.solution.response;
|
return data.solution.response;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
lastErr = 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;
|
throw lastErr;
|
||||||
|
|
|
||||||
|
|
@ -993,7 +993,8 @@ async function downloadMakerworldFiles(html, skipNames = new Set()) {
|
||||||
}
|
}
|
||||||
const original = dl.name || `instance-${inst.id}.3mf`;
|
const original = dl.name || `instance-${inst.id}.3mf`;
|
||||||
if (skipNames.has(original)) continue;
|
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) {
|
if (!resp.ok) {
|
||||||
console.warn(`MakerWorld CDN download ${resp.status} for ${original}`);
|
console.warn(`MakerWorld CDN download ${resp.status} for ${original}`);
|
||||||
problems.push({ message: `Downloading ${original} from MakerWorld failed (HTTP ${resp.status})` });
|
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) {
|
for (const dl of meta.downloads) {
|
||||||
if (!fileProcessor.isAllowed(dl.name)) continue; // skip readmes/images
|
if (!fileProcessor.isAllowed(dl.name)) continue; // skip readmes/images
|
||||||
if (skipNames.has(dl.name)) continue;
|
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; }
|
if (!resp.ok) { console.error(`Download failed (${resp.status}): ${dl.name}`); continue; }
|
||||||
const buffer = Buffer.from(await resp.arrayBuffer());
|
const buffer = Buffer.from(await resp.arrayBuffer());
|
||||||
const fileName = uniqueName(dl.name);
|
const fileName = uniqueName(dl.name);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue