invoke-ai/InvokeAI · error · ExternalProviderRequestError
DashScope task {task_id} timed out after {_TASK_POLL_TIMEOUT
Error message
DashScope task {task_id} timed out after {_TASK_POLL_TIMEOUT}s What it means
_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.
Source
Thrown at invokeai/app/services/external_generation/providers/alibabacloud.py:187
def _poll_task(
self,
base_url: str,
headers: dict[str, str],
task_id: str,
request: ExternalGenerationRequest,
request_id: str | None,
) -> ExternalGenerationResult:
"""Poll an async task until completion."""
task_url = f"{base_url}/api/v1/tasks/{task_id}"
start_time = time.monotonic()
poll_headers = {"Authorization": headers["Authorization"]}
first_poll = True
while True:
elapsed = time.monotonic() - start_time
if elapsed > _TASK_POLL_TIMEOUT:
raise ExternalProviderRequestError(f"DashScope task {task_id} timed out after {_TASK_POLL_TIMEOUT}s")
response = self._get_with_retry(task_url, headers=poll_headers, timeout=30, label="DashScope task poll")
if not response.ok:
raise ExternalProviderRequestError(
f"DashScope task poll failed with status {response.status_code}: {response.text}"
)
data = response.json()
output = data.get("output", {})
status = output.get("task_status")
if first_poll:
self._logger.info("DashScope task %s submitted (status=%s)", task_id, status)
first_poll = False
if status == "SUCCEEDED":
return self._parse_async_response(output, request, request_id)
if status in ("FAILED", "UNKNOWN"):View on GitHub (pinned to 0b6a024f2f)
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
Example fix
# before (alibabacloud.py) _TASK_POLL_TIMEOUT = 120 # after _TASK_POLL_TIMEOUT = 300
Defensive patterns
Strategy: retry
Validate before calling
# estimate feasibility: skip very large requests on slow regions or raise the timeout first
if request.width * request.height > LARGE_IMAGE_THRESHOLD:
increase_task_poll_timeout() Try / catch
try:
result = provider.generate(request)
except ExternalProviderRequestError as e:
if f'timed out after {_TASK_POLL_TIMEOUT}s' in str(e):
task_id = extract_task_id_from_logs(e)
result = query_dashscope_task_once(task_id) or resubmit(request)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- DashScope async request failed with status {response.status_
- DashScope async response missing task_id: {data}
- DashScope task poll failed with status {response.status_code
- DashScope task {task_id} failed: {message}
- Timeout exceeded
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/212684a94731dba2.
Report an issue: GitHub.