{"record":{"id":"212684a94731dba2","repo":"invoke-ai/InvokeAI","slug":"dashscope-task-task-id-timed-out-after-task-po","errorCode":null,"errorMessage":"DashScope task {task_id} timed out after {_TASK_POLL_TIMEOUT}s","messagePattern":"DashScope task (.+?) timed out after (.+?)s","errorType":"exception","errorClass":"ExternalProviderRequestError","httpStatus":null,"severity":"error","filePath":"invokeai/app/services/external_generation/providers/alibabacloud.py","lineNumber":187,"sourceCode":"\n    def _poll_task(\n        self,\n        base_url: str,\n        headers: dict[str, str],\n        task_id: str,\n        request: ExternalGenerationRequest,\n        request_id: str | None,\n    ) -> ExternalGenerationResult:\n        \"\"\"Poll an async task until completion.\"\"\"\n        task_url = f\"{base_url}/api/v1/tasks/{task_id}\"\n        start_time = time.monotonic()\n        poll_headers = {\"Authorization\": headers[\"Authorization\"]}\n        first_poll = True\n\n        while True:\n            elapsed = time.monotonic() - start_time\n            if elapsed > _TASK_POLL_TIMEOUT:\n                raise ExternalProviderRequestError(f\"DashScope task {task_id} timed out after {_TASK_POLL_TIMEOUT}s\")\n\n            response = self._get_with_retry(task_url, headers=poll_headers, timeout=30, label=\"DashScope task poll\")\n            if not response.ok:\n                raise ExternalProviderRequestError(\n                    f\"DashScope task poll failed with status {response.status_code}: {response.text}\"\n                )\n\n            data = response.json()\n            output = data.get(\"output\", {})\n            status = output.get(\"task_status\")\n\n            if first_poll:\n                self._logger.info(\"DashScope task %s submitted (status=%s)\", task_id, status)\n                first_poll = False\n\n            if status == \"SUCCEEDED\":\n                return self._parse_async_response(output, request, request_id)\n            if status in (\"FAILED\", \"UNKNOWN\"):","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/external_generation/providers/alibabacloud.py#L169-L205","documentation":"_poll_task polls the DashScope task status endpoint until SUCCEEDED/FAILED/UNKNOWN, but only up to _TASK_POLL_TIMEOUT seconds. If the task is still pending beyond that, the provider abandons it and raises ExternalProviderRequestError with the task id and timeout length. The remote task may still complete server-side; the client simply stops waiting.","triggerScenarios":"A DashScope async image task remains in a non-terminal state (PENDING/RUNNING) longer than _TASK_POLL_TIMEOUT seconds — very large images, provider congestion, or a stuck task.","commonSituations":"Peak-time DashScope queue delays; oversized/complex generation requests; monitoring task_id externally after timeout; polls blocked by network slowness consuming the wall-clock budget.","solutions":["Retry generation, ideally with a smaller/simpler request that finishes faster","Look up the task_id (from logs) directly via the DashScope task query API to see if it later succeeded","Increase _TASK_POLL_TIMEOUT in alibabacloud.py if your workloads legitimately need longer","Check DashScope service status/region health if timeouts are frequent"],"exampleFix":"# before (alibabacloud.py)\n_TASK_POLL_TIMEOUT = 120\n# after\n_TASK_POLL_TIMEOUT = 300","handlingStrategy":"retry","validationCode":"# estimate feasibility: skip very large requests on slow regions or raise the timeout first\nif request.width * request.height > LARGE_IMAGE_THRESHOLD:\n    increase_task_poll_timeout()","typeGuard":null,"tryCatchPattern":"try:\n    result = provider.generate(request)\nexcept ExternalProviderRequestError as e:\n    if f'timed out after {_TASK_POLL_TIMEOUT}s' in str(e):\n        task_id = extract_task_id_from_logs(e)\n        result = query_dashscope_task_once(task_id) or resubmit(request)\n    else:\n        raise","preventionTips":["Size _TASK_POLL_TIMEOUT to your largest expected generation","Record task_id (logs) so timed-out tasks can be recovered via the task query API","Prefer smaller/faster models for latency-sensitive flows","Monitor DashScope region health during peak hours"],"tags":["timeout","polling","dashscope","alibabacloud","async"],"backgroundTag":"request-timeout","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}