mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: dynamic timeouts — scale with image size, respect PROCESSING_TIMEOUT_S
Create timeout.ts utility for dynamic timeout computation. Replace hardcoded timeouts across the stack: - tool-factory worker: 30s → dynamic based on megapixels - Python bridge default: 300s → 600s (or env override) - background-removal: fixed → dynamic based on image size - OCR: fixed 600s → dynamic based on image size - seam-carving: 120s → dynamic based on image size - ExifTool: 30s → 60s - HEIC converter: 30s → 120s - SQLite busy_timeout: 5s → 10s
This commit is contained in:
@@ -218,7 +218,11 @@ function dispatcherRun(
|
||||
if (!proc || !proc.stdin || !dispatcherReady) return null;
|
||||
|
||||
const id = randomUUID();
|
||||
const timeout = options.timeout ?? 300000;
|
||||
const timeout =
|
||||
options.timeout ??
|
||||
(process.env.PROCESSING_TIMEOUT_S && parseInt(process.env.PROCESSING_TIMEOUT_S, 10) > 0
|
||||
? parseInt(process.env.PROCESSING_TIMEOUT_S, 10) * 1000
|
||||
: 600000);
|
||||
|
||||
return new Promise((resolvePromise, rejectPromise) => {
|
||||
const timer = setTimeout(() => {
|
||||
@@ -278,7 +282,11 @@ function runPythonPerRequest(
|
||||
} = {},
|
||||
): Promise<{ stdout: string; stderr: string }> {
|
||||
const scriptPath = resolve(PYTHON_DIR, scriptName);
|
||||
const timeout = options.timeout ?? 300000;
|
||||
const timeout =
|
||||
options.timeout ??
|
||||
(process.env.PROCESSING_TIMEOUT_S && parseInt(process.env.PROCESSING_TIMEOUT_S, 10) > 0
|
||||
? parseInt(process.env.PROCESSING_TIMEOUT_S, 10) * 1000
|
||||
: 600000);
|
||||
|
||||
return new Promise((resolvePromise, rejectPromise) => {
|
||||
const trySpawn = (pythonBin: string, isFallback: boolean) => {
|
||||
|
||||
Reference in New Issue
Block a user