infiniflow/ragflow · error · TimeoutError

Execution timed out after {timeout} seconds

Error message

Execution timed out after {timeout} seconds

What it means

Raised as TimeoutError when the Aliyun Code Interpreter returns a ServerError whose text contains 'timeout', after the provider enforced its 30-second hard cap (timeout = min(timeout, 30)). It means the sandboxed code did not finish within the allowed window on the Aliyun side.

Source

Thrown at agent/sandbox/providers/aliyun_codeinterpreter.py:308

            return ExecutionResult(
                stdout=stdout,
                stderr=stderr,
                exit_code=exit_code,
                execution_time=execution_time,
                metadata={
                    "instance_id": instance_id,
                    "language": normalized_lang,
                    "context_id": result.get("contextId") if isinstance(result, dict) else None,
                    "timeout": timeout,
                    "result_present": structured_result.get("present", False),
                    "result_value": structured_result.get("value"),
                    "result_type": structured_result.get("type"),
                },
            )

        except ServerError as e:
            if "timeout" in str(e).lower():
                raise TimeoutError(f"Execution timed out after {timeout} seconds")
            raise RuntimeError(f"Failed to execute code: {str(e)}")
        except Exception as e:
            raise RuntimeError(f"Unexpected error during execution: {str(e)}")

    def destroy_instance(self, instance_id: str) -> bool:
        """
        Destroy an Aliyun Code Interpreter instance.

        Args:
            instance_id: ID of the instance to destroy

        Returns:
            True if destruction successful, False otherwise
        """
        if not self._initialized or not self._config:
            raise RuntimeError("Provider not initialized. Call initialize() first.")

        try:

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Reduce the work per execute_code call — split the code so each cell finishes well under 30s.
  2. Set explicit lower timeouts on any network/IO performed inside the sandbox code.
  3. Preload heavy imports at instance creation time so execution cells stay fast.
  4. Treat 30s as a hard platform limit: no configuration raises it.

Example fix

# before
result = provider.execute_code(instance_id, slow_code, "python", timeout=120)  # clamped to 30, then times out

# after: chunk the work into sub-30s cells
for chunk in split_work(slow_code, budget_s=25):
    result = provider.execute_code(instance_id, chunk, "python", timeout=25)
Defensive patterns

Strategy: try-catch

Validate before calling

# Reject workloads that cannot fit the platform's 30s cap before paying for a call
EFFECTIVE_CAP = 30
if estimated_workload_seconds is not None and estimated_workload_seconds > EFFECTIVE_CAP - 5:
    raise ValueError("Workload cannot finish within the Aliyun 30s execution cap; split it")

Try / catch

try:
    result = provider.execute_code(instance_id, code, "python", timeout=30)
except TimeoutError:
    # partial state may exist in the sandbox context; re-run a smaller cell
    result = provider.execute_code(instance_id, reduced_code, "python", timeout=25)

Prevention

When it happens

Trigger: Executing code that blocks (sleep, long loop, big computation) past the effective timeout; requesting timeout>30 which gets clamped to 30 and then exceeded; slow imports/cold starts inside the sandbox consuming the whole budget.

Common situations: Porting code from the self-managed provider (which allows longer timeouts) to Aliyun's 30s cap; heavy data processing in a notebook-style cell; network calls inside sandboxed code without their own timeouts.

Understand the failure class

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/ee4b0f0da0d1fddf. Report an issue: GitHub.