{"record":{"id":"8fd4f2d31b64e4dd","repo":"iflytek/astron-agent","slug":"code-execution-timeout-error","errorCode":"CODE_EXECUTION_TIMEOUT_ERROR","errorMessage":"Code execution timeout","messagePattern":"Code execution timeout","errorType":"error_code","errorClass":"CustomExceptionCD","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/code/executor/ifly/ifly_executor_v2.py","lineNumber":138,"sourceCode":"            cause_error=\"Retry attempts exceeded 5 times\",\n        )\n\n    def _handle_error_response(self, resp_json: dict, span: Span) -> None:\n        \"\"\"\n        Handle error response and raise appropriate exception.\n\n        :param resp_json: Response json dictionary\n        :param span: Tracing span for logging\n        :raises CustomExceptionCD: Based on error type\n        \"\"\"\n\n        err_type = resp_json.get(\"type\", \"\")\n        resp_message = resp_json.get(\"message\", \"\")\n        span.add_error_event(f\"err_type: {err_type}\")\n        span.add_error_event(f\"response message: {resp_message}\")\n\n        if err_type == \"exec_code_timeout\":\n            raise CustomExceptionCD(\n                err_code=CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR.code,\n                err_msg=\"Code execution timeout\",\n            )\n        elif err_type == \"exec_code_failed\":\n            raise CustomExceptionCD(\n                err_code=CodeEnum.CODE_EXECUTION_ERROR.code,\n                err_msg=self._remove_traceback_stdin_line(resp_message),\n            )\n        else:\n            raise CustomExceptionCD(\n                err_code=CodeEnum.CODE_EXECUTION_ERROR.code,\n                err_msg=\"Code execution failed\",\n            )\n\n    def _remove_traceback_stdin_line(self, traceback_str: str) -> str:\n        \"\"\"\n        Remove traceback line with V2-specific preprocessing.\n","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/code/executor/ifly/ifly_executor_v2.py#L120-L156","documentation":"CODE_EXECUTION_TIMEOUT_ERROR is raised by _handle_error_response when the iFly v2 code service responds with type == 'exec_code_timeout', meaning the sandbox killed the user's code because it exceeded its execution time budget. The err_msg is the fixed string 'Code execution timeout'.","triggerScenarios":"A code node whose script runs longer than the sandbox's time limit — infinite loops, very large data processing, long sleeps, or blocking network calls without timeouts inside the user code.","commonSituations":"Users paste heavy data-wrangling scripts into code nodes; a loop that never terminates after an upstream node changed its output shape; sandbox timeout lowered via config making previously-fine scripts fail.","solutions":["Optimize or shorten the code in the code node: vectorize loops, remove sleeps, add internal timeouts to network calls.","Split the work into multiple code nodes or process data in chunks.","Raise the code-execution timeout limit in the executor/sandbox configuration if legitimate long runs are expected.","Fix the root cause if an upstream node change made a loop non-terminating (e.g. unexpected empty input)."],"exampleFix":"# before (inside user code node)\nwhile True:\n    process(rows)\n// after\nimport itertools\nfor _ in itertools.islice(iter_process(rows), MAX_ITERATIONS):\n    pass","handlingStrategy":"validation","validationCode":"# static sanity check before submitting user code\nimport ast\ntree = ast.parse(user_code)\nif any(isinstance(n, ast.While) for n in ast.walk(tree)) and \"break\" not in user_code and \"return\" not in user_code:\n    raise ValueError(\"while loop without break/return likely exceeds execution timeout\")","typeGuard":null,"tryCatchPattern":"try:\n    output = await executor.execute(...)\nexcept CustomExceptionCD as e:\n    if e.err_code == CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR.code:\n        logger.error(\"code node exceeded time budget; chunk the workload\")\n        output = partial_result_or_empty","preventionTips":["Set internal timeouts on any network calls inside code nodes","Bound loops with explicit iteration limits","Profile heavy scripts against the sandbox timeout before production use"],"tags":["timeout","code-execution","workflow"],"backgroundTag":"request-timeout","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}