fix: extend image request timeout to 15 minutes

This commit is contained in:
cneicy committed 2026-10-05 05:14:27 +08:00
1 parent 99e087112b
commit d9d69000e9
3 files changed
+10 -10

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
const MAX_BYTES = 64 * 1024 * 1024;
const MAX_EDIT_BYTES = 20 * 1024 * 1024;
const TIMEOUT_MS = 180_000;
const TIMEOUT_MS = 15 * 60_000;
const QUALITY = new Set(['auto', 'low', 'medium', 'high', 'standard', 'hd']);
const BACKGROUND = new Set(['auto', 'transparent', 'opaque']);
const OUTPUT_FORMAT = new Set(['png', 'jpeg', 'webp']);
@@ -56,7 +56,7 @@ async function operation(signal, work) {
if (controller.signal.aborted) throw new Error('Request aborted.');
return await work(controller.signal);
} catch (error) {
if (controller.signal.aborted) throw new Error(timedOut ? 'Request timed out after 180 seconds.' : 'Request aborted.');
if (controller.signal.aborted) throw new Error(timedOut ? `Request timed out after ${TIMEOUT_MS / 1000} seconds.` : 'Request aborted.');
throw error;
} finally {
clearTimeout(timer);