mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user