{"record":{"id":"754b125af0db978b","repo":"invoke-ai/InvokeAI","slug":"unexpected-error-while-pausing-queue-e","errorCode":null,"errorMessage":"Unexpected error while pausing queue: {e}","messagePattern":"Unexpected error while pausing queue: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/session_queue.py","lineNumber":291,"sourceCode":"        return ApiDependencies.invoker.services.session_processor.resume()\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Unexpected error while resuming queue: {e}\")\n\n\n@session_queue_router.put(\n    \"/{queue_id}/processor/pause\",\n    operation_id=\"pause\",\n    responses={200: {\"model\": SessionProcessorStatus}},\n)\ndef pause(\n    current_user: AdminUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n) -> SessionProcessorStatus:\n    \"\"\"Pauses session processor. Admin only.\"\"\"\n    try:\n        return ApiDependencies.invoker.services.session_processor.pause()\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Unexpected error while pausing queue: {e}\")\n\n\n@session_queue_router.put(\n    \"/{queue_id}/cancel_all_except_current\",\n    operation_id=\"cancel_all_except_current\",\n    responses={200: {\"model\": CancelAllExceptCurrentResult}},\n)\ndef cancel_all_except_current(\n    current_user: CurrentUserOrDefault,\n    queue_id: str = Path(description=\"The queue id to perform this operation on\"),\n) -> CancelAllExceptCurrentResult:\n    \"\"\"Immediately cancels all queue items except in-processing items. Non-admin users can only cancel their own items.\"\"\"\n    try:\n        # Admin users can cancel all items, non-admin users can only cancel their own\n        user_id = None if current_user.is_admin else current_user.user_id\n        return ApiDependencies.invoker.services.session_queue.cancel_all_except_current(\n            queue_id=queue_id, user_id=user_id\n        )","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/session_queue.py#L273-L309","documentation":"Mirror of error 146 for the pause endpoint (PUT /{queue_id}/processor/pause, admin only): any exception from SessionProcessor.pause() is converted into a 500 whose detail includes the exception text. Thrown when the processor cannot be paused, typically due to unexpected internal state rather than a modeled client error.","triggerScenarios":"Pausing while the processor is mid-transition, before it is started, or when the internal pause routine throws.","commonSituations":"Race between pause and resume calls from an admin UI and a script; processor not yet initialized at app startup; queue processor crash leaving state inconsistent.","solutions":["Inspect the embedded exception message in the detail","Check processor status first; skip pause if already paused/stopped","Restart the app if the processor state is inconsistent after a crash","Avoid concurrent pause/resume from multiple clients"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const s = await (await fetch('/api/v1/queue/default/processor/status')).json();\nif (!s.is_started || s.status === 'paused') console.log('pause unnecessary');","typeGuard":"function canPause(s) { return !!s && s.is_started === true && s.status !== 'paused'; }","tryCatchPattern":"try {\n  const res = await fetch('/api/v1/queue/default/processor/pause', {method:'PUT'});\n  if (res.status === 500) console.error('pause failed:', (await res.json()).detail);\n} catch (e) { console.error('network error during pause:', e); }","preventionTips":["Only pause when status shows the processor active","Avoid concurrent pause/resume from multiple admin sessions","Restart the app if processor state is inconsistent after a crash","Confirm admin authorization before the call"],"tags":["fastapi","http-500","queue","processor","api"],"backgroundTag":"api-internal-server-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}