{"record":{"id":"3a885baaa83827ec","repo":"n8n-io/n8n","slug":"auto-shutdown-timeout-must-be-non-negative-got-a","errorCode":null,"errorMessage":"Auto shutdown timeout must be non-negative, got {auto_shutdown_timeout}","messagePattern":"Auto shutdown timeout must be non-negative, got (.+?)","errorType":"validation","errorClass":"ConfigurationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/task-runner-python/src/config/task_runner_config.py","lineNumber":90,"sourceCode":"    @classmethod\n    def from_env(cls):\n        grant_token = read_str_env(ENV_GRANT_TOKEN, \"\")\n        if not grant_token:\n            raise ConfigurationError(\n                \"Environment variable N8N_RUNNERS_GRANT_TOKEN is required\"\n            )\n\n        task_timeout = read_int_env(ENV_TASK_TIMEOUT, DEFAULT_TASK_TIMEOUT)\n        if task_timeout <= 0:\n            raise ConfigurationError(\n                f\"Task timeout must be positive, got {task_timeout}\"\n            )\n\n        auto_shutdown_timeout = read_int_env(\n            ENV_AUTO_SHUTDOWN_TIMEOUT, DEFAULT_AUTO_SHUTDOWN_TIMEOUT\n        )\n        if auto_shutdown_timeout < 0:\n            raise ConfigurationError(\n                f\"Auto shutdown timeout must be non-negative, got {auto_shutdown_timeout}\"\n            )\n\n        graceful_shutdown_timeout = read_int_env(\n            ENV_GRACEFUL_SHUTDOWN_TIMEOUT, DEFAULT_SHUTDOWN_TIMEOUT\n        )\n        if graceful_shutdown_timeout <= 0:\n            raise ConfigurationError(\n                f\"Graceful shutdown timeout must be positive, got {graceful_shutdown_timeout}\"\n            )\n\n        max_payload_size = read_int_env(ENV_MAX_PAYLOAD_SIZE, DEFAULT_MAX_PAYLOAD_SIZE)\n        if max_payload_size > PIPE_MSG_MAX_SIZE:\n            raise ConfigurationError(\n                f\"Max payload size of {max_payload_size} bytes exceeds pipe message limit of {PIPE_MSG_MAX_SIZE} bytes. Reduce {ENV_MAX_PAYLOAD_SIZE}.\"\n            )\n\n        return cls(","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/task-runner-python/src/config/task_runner_config.py#L72-L108","documentation":"Thrown by TaskRunnerConfig.from_env when the auto-shutdown timeout read from N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT is negative. A value of 0 disables auto-shutdown (is_auto_shutdown_enabled returns False); negative values are meaningless and rejected. The timeout controls how long the runner idles before shutting down when no tasks arrive.","triggerScenarios":"The environment variable ENV_AUTO_SHUTDOWN_TIMEOUT is set to a negative number. The check `if auto_shutdown_timeout < 0` fires in from_env. The property is_auto_shutdown_enabled checks `self.auto_shutdown_timeout > 0`, so 0 is a valid 'disabled' sentinel.","commonSituations":"Accidentally setting a negative value through a typo or miscalculation. Misunderstanding that 0 means 'disabled' and trying negative values to express the same intent. Deployment template arithmetic producing a negative result.","solutions":["Set N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT to 0 to disable auto-shutdown, or a positive number of seconds.","Check the environment variable for stray negative signs.","Restart the runner after correcting the value."],"exampleFix":"# before\nexport N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT=-1\n# after — disable auto-shutdown\nexport N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT=0\n# after — shut down after 300s idle\nexport N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT=300","handlingStrategy":"validation","validationCode":"auto_shutdown = int(os.environ.get('N8N_RUNNERS_AUTO_SHUTDOWN_TIMEOUT', '0'))\nif auto_shutdown < 0:\n    raise ValueError(f'Auto shutdown timeout must be >= 0, got {auto_shutdown}')","typeGuard":null,"tryCatchPattern":"from config.task_runner_config import ConfigurationError\n\ntry:\n    config = TaskRunnerConfig.from_env()\nexcept ConfigurationError as e:\n    print(f'Fix configuration: {e}')\n    sys.exit(1)","preventionTips":["Use 0 to disable auto-shutdown, or a positive value to enable it.","Never use negative values for timeout configurations.","Validate all timeout values in deployment scripts."],"tags":["task-runner","python","configuration","timeout","startup"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}