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:
ashim-hq
2026-04-20 21:46:07 +08:00
parent 00041d535d
commit be254f9ca6
9 changed files with 59 additions and 12 deletions
+2 -2
View File
@@ -51,7 +51,7 @@ export async function inspectMetadata(buffer: Buffer, filename: string): Promise
try {
await writeFile(tempPath, buffer);
const { stdout } = await execFileAsync(bin, ["-json", "-G", "-struct", "-n", tempPath], {
timeout: 30_000,
timeout: 60_000,
maxBuffer: 10 * 1024 * 1024,
});
@@ -126,7 +126,7 @@ export async function writeMetadata(
try {
await writeFile(tempPath, buffer);
await execFileAsync(bin, ["-overwrite_original", ...tags, tempPath], {
timeout: 30_000,
timeout: 60_000,
maxBuffer: 10 * 1024 * 1024,
});
return await readFile(tempPath);