{"record":{"id":"bf4d6628b9f677d9","repo":"unslothai/unsloth","slug":"transcription-cancelled-bf4d66","errorCode":null,"errorMessage":"Transcription cancelled.","messagePattern":"Transcription cancelled\\.","errorType":"http","errorClass":"SttTranscriptionCancelledError","httpStatus":499,"severity":"info","filePath":"studio/backend/core/inference/stt_transformers_worker.py","lineNumber":274,"sourceCode":"                        \"is_multilingual\": (\n                            is_multilingual if isinstance(is_multilingual, bool) else None\n                        ),\n                    },\n                )\n            elif kind == \"transcribe\":\n                if engine is None:\n                    raise SttWorkerError(\"The dictation worker has no model loaded.\")\n                cancellable = bool(command.get(\"cancellable\"))\n                text = transcribe_window(\n                    engine[0],\n                    engine[1],\n                    command[\"audio\"],\n                    command.get(\"generate_kwargs\") or {},\n                    cancel_event if cancellable else None,\n                )\n                if cancellable and cancel_event.is_set():\n                    from core.inference.stt_sidecar import SttTranscriptionCancelledError\n                    raise SttTranscriptionCancelledError(\"Transcription cancelled.\")\n                _send(resp_queue, {\"type\": \"text\", \"text\": text})\n            elif kind == \"shutdown\":\n                _send(resp_queue, {\"type\": \"shutdown_ack\"})\n                return\n            else:\n                _send(\n                    resp_queue,\n                    {\n                        \"type\": \"error\",\n                        \"kind\": \"SttWorkerError\",\n                        \"error\": f\"Unknown command '{kind}'.\",\n                    },\n                )\n        except BaseException as exc:  # noqa: BLE001 - every failure is reported, then handled\n            _send(resp_queue, _error_response(exc))\n            if kind == \"load\":\n                # Nothing is resident after a failed load, and the attempt may\n                # already have taken a context; exiting returns it.","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/stt_transformers_worker.py#L256-L292","documentation":"Raised in the STT worker child's command loop after transcribe_window returns: the command was marked cancellable and the shared cancel event is set, so the child reports SttTranscriptionCancelledError instead of sending the (possibly truncated) text. It is the child-side twin of the parent's cancellation check.","triggerScenarios":"Sending a {'type': 'transcribe', 'cancellable': True, ...} command to the worker while the parent sets cancel_event — either mid-generation (stopping the beam search via the StoppingCriteria) or right as it finishes.","commonSituations":"A stop button on a live dictation session; per-request timeouts backed by an event; racing a shutdown with an in-flight transcription window.","solutions":["Catch SttTranscriptionCancelledError on the parent side (it arrives via the error channel) and map it to a 'cancelled' response, not a 500.","If partial text is wanted despite cancellation, send cancellable=False and rely on the stop criteria only to shorten generation.","Ensure the UI stops treating a cancelled window as a failed request."],"exampleFix":"# before\nresp = worker_client.transcribe(pcm, generate_kwargs, cancellable=True)\n# worker raises SttTranscriptionCancelledError -> surfaced as generic error\n\n# after\ntry:\n    resp = worker_client.transcribe(pcm, generate_kwargs, cancellable=True)\nexcept SttTranscriptionCancelledError:\n    resp = {'text': '', 'cancelled': True}","handlingStrategy":"try-catch","validationCode":"if cancellable and cancel_event is not None and cancel_event.is_set():\n    return {'text': '', 'cancelled': True}","typeGuard":null,"tryCatchPattern":"from core.inference.stt_sidecar import SttTranscriptionCancelledError\ntry:\n    text = worker.transcribe(pcm, kwargs, cancellable=True)\nexcept SttTranscriptionCancelledError:\n    text = ''  # user stopped; not an error","preventionTips":["Set cancellable=False for fire-and-forget windows where partial text is still useful.","Keep one owner per cancel event (the request handler), and clear or replace it per request.","Distinguish 'cancelled' from 'failed' in the response contract so the UI renders them differently."],"tags":["stt","cancellation","worker","concurrency"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}