{"record":{"id":"7809686067408e5c","repo":"iflytek/astron-agent","slug":"code-execution-timeout-error-code-execution-error-message","errorCode":"CODE_EXECUTION_TIMEOUT_ERROR|CODE_EXECUTION_ERROR","errorMessage":"error_message[:MAX_ERROR_MESSAGE_LENGTH]","messagePattern":"error_message\\[:MAX_ERROR_MESSAGE_LENGTH\\]","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/engine/nodes/code/executor/langchain/langchain_executor.py","lineNumber":109,"sourceCode":"                    source_file.write(code)\n                sandbox = _FilePyodideSandbox(\n                    source_path,\n                    allow_env=False,\n                    allow_read=[\"node_modules\", source_path],\n                    allow_write=False,\n                    allow_net=False,\n                    allow_run=False,\n                    allow_ffi=False,\n                )\n                result = await sandbox.execute(\n                    code,\n                    timeout_seconds=bounded_timeout,\n                    memory_limit_mb=bounded_memory_limit,\n                )\n            if result.status == \"success\":\n                return result.stdout if result.stdout else \"\"\n            error_message = (result.stderr or \"Code execution failed\").strip()\n            raise CustomException(\n                err_code=(\n                    CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR\n                    if _is_timeout_error(error_message)\n                    else CodeEnum.CODE_EXECUTION_ERROR\n                ),\n                err_msg=error_message[:MAX_ERROR_MESSAGE_LENGTH],\n            )\n\n        except CustomException as e:\n            raise e\n\n        except Exception as e:\n            raise CustomException(\n                err_code=CodeEnum.CODE_EXECUTION_ERROR,\n                cause_error=e,\n            ) from e\n\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/engine/nodes/code/executor/langchain/langchain_executor.py#L91-L127","documentation":"In langchain_executor.execute, when the sandboxed subprocess result reports a non-success status, the executor raises CODE_EXECUTION_TIMEOUT_ERROR if the stderr matches the timeout heuristic (_is_timeout_error) or CODE_EXECUTION_ERROR otherwise. The message is the process stderr (or 'Code execution failed'), truncated to MAX_ERROR_MESSAGE_LENGTH. It represents the local/isolated sandbox refusing or failing the run.","triggerScenarios":"Calling execute() with code that exits nonzero: raises an uncaught Python/JS exception (stderr contains traceback), exceeds bounded_timeout so the runner kills it (timeout error string), violates memory_limit_mb, or the runner itself crashes and writes errors to stderr.","commonSituations":"Timeouts from infinite loops or oversized workloads; unhandled exceptions from wrong assumptions about input variables; memory-limit kills on large dataframes; stderr noise from warnings combined with a real error overflowing truncation.","solutions":["Read the truncated stderr message in the error to find the exact exception or timeout indicator.","Fix the code-node script (imports, null checks, logic) if it's an execution error.","Reduce workload or increase timeout/memory bounds if the error is a timeout/OOM kill.","Add explicit error handling and prints in user code to fail fast with clear messages instead of deep tracebacks."],"exampleFix":"// before\ncode = \"for i in range(len(data)): process(data[i])  # may exceed timeout\"\n// after\ncode = \"\\nimport signal\\n# chunk the work and guard inputs\\nassert data, 'empty input'\\nfor row in data[:MAX_ROWS]:\\n    process(row)\"","handlingStrategy":"validation","validationCode":"# pre-flight compile check of user code before sandbox execution\ntry:\n    compile(user_code, \"<code_node>\", \"exec\")\nexcept SyntaxError as e:\n    raise ValueError(f\"code node syntax error before execution: {e}\")","typeGuard":"def looks_like_timeout(stderr: str) -> bool:\n    s = (stderr or \"\").lower()\n    return \"timeout\" in s or \"timed out\" in s or \"killed\" in s","tryCatchPattern":"try:\n    output = await executor.execute(language, code, timeout, span)\nexcept CustomException as e:\n    if e.err_code in (CodeEnum.CODE_EXECUTION_TIMEOUT_ERROR, CodeEnum.CODE_EXECUTION_ERROR):\n        logger.error(\"sandbox failure: %s\", e.err_msg)\n        output = \"\"","preventionTips":["Validate/compile code-node scripts at design time","Keep workloads within the sandbox timeout and memory bounds","Print clear error messages in user code so stderr stays readable after truncation"],"tags":["code-execution","timeout","stderr","sandbox"],"backgroundTag":"code-execution-failed","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"}