From 287fe2b8207669e63041e59832cee0f838cb49ae Mon Sep 17 00:00:00 2001 From: Coder Date: Thu, 27 Aug 2026 22:34:28 +0700 Subject: [PATCH] fix(telegram-remote): poll Whishper through status 1 (processing) Whishper job lifecycle: 0=created, 1=processing (tens of seconds), 2/3=finished. The poll loop treated any status != -1 as terminal and threw 'job finished without text (status 1)' mid-transcription. Keep polling on -1/0/1; only finished statuses with empty text are errors. --- packages/telegram-remote/lib/whisper.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/telegram-remote/lib/whisper.js b/packages/telegram-remote/lib/whisper.js index 0dcce6c..91c3833 100644 --- a/packages/telegram-remote/lib/whisper.js +++ b/packages/telegram-remote/lib/whisper.js @@ -6,8 +6,8 @@ * POST {base}/api/transcriptions multipart fields: file, language, * modelSize, device (cuda|cpu), sourceUrl * GET {base}/api/transcriptions/{id} - * Job status -1 = queued/running; statuses 0/1/2 = terminal; a successful - * terminal job has a non-empty result.text. + * Job status 0 = created/queued, 1 = processing, 2/3 = finished; a finished + * job has a non-empty result.text on success. */ const POLL_INTERVAL_MS = 1500; @@ -78,8 +78,12 @@ export async function transcribeAudio({ baseUrl, model, device, language, timeou } const text = job?.result?.text; if (typeof text === "string" && text.trim().length > 0) return text; - if (job?.status !== -1) { - throw new Error("whisper: job finished without text (status " + String(job?.status) + ")"); + // Whishper lifecycle (verified on this server): 0 = created/queued, + // 1 = processing (can last tens of seconds), 2/3 = finished. + const status = job?.status; + const running = status === -1 || status === 0 || status === 1; + if (!running) { + throw new Error("whisper: job finished without text (status " + String(status) + ")"); } } }