fix: give remove-background job timeouts an actionable failure message (#518)

Extends the worker.ts timeout failure detail with actionable guidance (first-run model download, input too large for CPU inference, or busy/unavailable worker) while preserving the "Timed out after Ns" prefix so error_code classification, SSE terminal replay, and existing timeout assertions keep working. Adds a test assertion for the guidance.

Fixes #494
This commit is contained in:
Matt Van Horn
2026-07-14 22:43:08 +08:00
committed by GitHub
parent 73e48c24d1
commit 58121f205f
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -369,7 +369,7 @@ async function processToolJob(job: Job<ToolJobData>): Promise<ToolJobResult> {
const finalError = isCanceled
? "Canceled"
: isTimeout
? `Timed out after ${Math.round(timeoutMs / 1000)}s`
? `Timed out after ${Math.round(timeoutMs / 1000)}s. On the first run the background-removal model may still be downloading; the image may be too large for CPU inference; or the worker may be busy or unavailable. Retry once the model has downloaded, or try a smaller image.`
: errorMessage;
// Log genuine processing faults at error level (clients only ever see
@@ -116,6 +116,10 @@ describe("Worker timeout classification", () => {
// Error message must mention timeout
const error = finalRow?.error as { message: string };
expect(error.message).toMatch(/timed out after 1s/i);
// Fail-fast message must include actionable guidance (issue #494)
expect(error.message).toMatch(
/model may still be downloading|too large for CPU|worker may be busy/i,
);
// Both attempts ran (attempts column is set at the start of each attempt)
expect(finalRow?.attempts).toBe(2);