fix(telegram-remote): poll Whishper through status 1 (processing)
All checks were successful
build-and-publish / build-test (push) Successful in 27s
build-and-publish / publish (push) Has been skipped

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.
This commit is contained in:
2026-08-27 22:34:28 +07:00
parent 8ccffb2901
commit 287fe2b820

View File

@@ -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) + ")");
}
}
}