calesthio/OpenMontage · error · TimeoutError

Ark task {task_id} did not finish within {timeout}s

Error message

Ark task {task_id} did not finish within {timeout}s

What it means

TimeoutError raised in _poll_task when time.monotonic() passes the deadline (timeout_seconds, default 1200) while the task is still queued or running. The generation may still complete server-side, but this client stops waiting. The task itself is not cancelled by this raise, so it can consume credits.

Source

Thrown at tools/video/seedance_ark.py:1331

    ) -> dict[str, Any]:
        interval = float(inputs.get("poll_interval_seconds", 3))
        timeout = float(inputs.get("timeout_seconds", 1200))
        if not 0 <= interval <= 60:
            raise ValueError("poll_interval_seconds must be between 0 and 60")
        if timeout <= 0:
            raise ValueError("timeout_seconds must be greater than 0")
        deadline = time.monotonic() + timeout
        while True:
            task = self._query_task(task_id, api_key)
            status = str(task.get("status", "")).lower()
            if status in self.TERMINAL_STATUSES:
                return task
            if status not in {"queued", "running"}:
                raise RuntimeError(
                    f"Ark returned unknown task status: {status or '<empty>'}"
                )
            if time.monotonic() >= deadline:
                raise TimeoutError(
                    f"Ark task {task_id} did not finish within {timeout}s"
                )
            time.sleep(interval)

    @staticmethod
    def _download_video(video_url: str, output_path: Path) -> None:
        import requests

        response = requests.get(video_url, timeout=120)
        response.raise_for_status()
        output_path.parent.mkdir(parents=True, exist_ok=True)
        partial = output_path.with_name(output_path.name + ".part")
        partial.write_bytes(response.content)
        partial.replace(output_path)

    @staticmethod
    def _validate_task_id(task_id: Any) -> None:
        value = str(task_id or "")

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Increase timeout_seconds (e.g. 1800-3600) for long or high-resolution jobs.
  2. Catch TimeoutError and recover the finished result later by querying the task_id directly instead of resubmitting (validate with the same TASK_ID_PATTERN).
  3. Submit fewer concurrent tasks so queue wait shrinks.
  4. If you must abandon, cancel via the task DELETE endpoint to avoid paying for an orphaned generation.

Example fix

# before
inputs = {"timeout_seconds": 300}  # 5 min, too short for 1080p

# after
inputs = {"timeout_seconds": 2400}  # 40 min budget
Defensive patterns

Strategy: try-catch

Validate before calling

inputs["timeout_seconds"] = max(1800, float(inputs.get("timeout_seconds", 1200)))  # headroom for long jobs

Try / catch

try:
    result = tool.run(inputs)
except TimeoutError:
    task = tool._query_task(task_id, api_key)  # task may still complete server-side
    if str(task.get("status", "")).lower() in tool.TERMINAL_STATUSES:
        return task
    raise

Prevention

When it happens

Trigger: Long generations (high resolution, multi-second videos, heavy reference sets) exceeding the deadline; congested Ark queues during peak hours; or an undersized timeout_seconds paired with a slow model.

Common situations: First runs on sora-2-pro-class or long-duration models where 20 minutes is not enough; batch jobs where queue time stacks behind many submitted tasks.

Understand the failure class

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/e622480259e957a3. Report an issue: GitHub.