{"record":{"id":"eb1114f038209414","repo":"infiniflow/ragflow","slug":"execution-timed-out-after-exec-timeout-seconds-eb1114","errorCode":null,"errorMessage":"Execution timed out after {exec_timeout} seconds","messagePattern":"Execution timed out after (.+?) seconds","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"agent/sandbox/providers/self_managed.py","lineNumber":178,"sourceCode":"                stderr=result.get(\"stderr\", \"\"),\n                exit_code=result.get(\"exit_code\", 0),\n                execution_time=execution_time,\n                metadata={\n                    \"status\": result.get(\"status\"),\n                    \"time_used_ms\": result.get(\"time_used_ms\"),\n                    \"memory_used_kb\": result.get(\"memory_used_kb\"),\n                    \"detail\": result.get(\"detail\"),\n                    \"instance_id\": instance_id,\n                    \"artifacts\": result.get(\"artifacts\", []),\n                    \"result_present\": structured_result.get(\"present\", False),\n                    \"result_value\": structured_result.get(\"value\"),\n                    \"result_type\": structured_result.get(\"type\"),\n                },\n            )\n\n        except requests.Timeout:\n            execution_time = time.time() - start_time\n            raise TimeoutError(f\"Execution timed out after {exec_timeout} seconds\")\n\n        except requests.RequestException as e:\n            raise RuntimeError(f\"HTTP request failed: {str(e)}\")\n\n    def destroy_instance(self, instance_id: str) -> bool:\n        \"\"\"\n        Destroy a sandbox instance.\n\n        Note: For self-managed provider, instances are returned to the\n        internal pool automatically by executor_manager after execution.\n        This is a no-op for tracking purposes.\n\n        Args:\n            instance_id: ID of the instance to destroy\n\n        Returns:\n            True (always succeeds for self-managed)\n        \"\"\"","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/self_managed.py#L160-L196","documentation":"Raised by SelfManagedProvider.execute_code() when the requests.post call to {endpoint}/run raises requests.Timeout — the remote sandbox service did not answer within exec_timeout seconds (the per-call timeout argument, or the provider's configured timeout as fallback). The provider converts it to a built-in TimeoutError, deliberately distinguishing 'service never answered' from non-zero exits inside the sandbox.","triggerScenarios":"Executed code running longer than the timeout passed to execute_code() while the sandbox service holds the connection; a low provider timeout configured at initialize() with a larger per-call timeout argument NOT passed (per-call timeout wins: exec_timeout = timeout or self.timeout); sandbox service hung or network black-holing the connection.","commonSituations":"Long computations (training loops, big sorts) exceeding a 30s default; forgetting that the timeout parameter of execute_code() must be raised for heavy work; a stuck executor container; network middleboxes dropping idle HTTP connections so the response never arrives.","solutions":["Pass a larger timeout to execute_code(instance_id, code, language, timeout=N) sized to the workload.","Raise the provider-level 'timeout' in the initialize() config so the fallback covers unparameterized calls.","Split long jobs into resumable chunks with per-chunk progress written by the executed code.","If timeouts persist for fast code, check sandbox-service health/network — a hung service times out even on trivial payloads."],"exampleFix":"# before\nresult = provider.execute_code(instance_id, code, \"python\")  # default timeout\n\n# after\nresult = provider.execute_code(instance_id, code, \"python\", timeout=300)","handlingStrategy":"retry","validationCode":"timeout_needed = estimate_runtime(code)\nassert provider.timeout >= timeout_needed or pass_explicit_timeout  # plan ahead\nresult = provider.execute_code(instance_id, code, \"python\", timeout=max(30, timeout_needed))","typeGuard":null,"tryCatchPattern":"import time\nfor attempt in range(2):\n    try:\n        result = provider.execute_code(instance_id, code, \"python\", timeout=300)\n        break\n    except TimeoutError:\n        if attempt == 1:\n            raise\n        time.sleep(2)","preventionTips":["Always pass an explicit timeout sized to the workload when calling execute_code().","Make executed code emit progress artifacts so genuinely-stuck runs are distinguishable from slow ones.","Don't retry TimeoutError with the same timeout — the code will time out again; raise the limit or split the job."],"tags":["sandbox","timeout","self-managed-provider","network"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}