{"record":{"id":"134acd463a390cde","repo":"conductor-oss/conductor","slug":"long-poll-timeout-value-cannot-be-more-than-5-seco","errorCode":null,"errorMessage":"Long Poll Timeout value cannot be more than 5 seconds","messagePattern":"Long Poll Timeout value cannot be more than 5 seconds","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"core/src/main/java/com/netflix/conductor/service/ExecutionService.java","lineNumber":114,"sourceCode":"    }\n\n    public Task poll(String taskType, String workerId, String domain) {\n\n        List<Task> tasks = poll(taskType, workerId, domain, 1, 100);\n        if (tasks.isEmpty()) {\n            return null;\n        }\n        return tasks.get(0);\n    }\n\n    public List<Task> poll(String taskType, String workerId, int count, int timeoutInMilliSecond) {\n        return poll(taskType, workerId, null, count, timeoutInMilliSecond);\n    }\n\n    public List<Task> poll(\n            String taskType, String workerId, String domain, int count, int timeoutInMilliSecond) {\n        if (timeoutInMilliSecond > MAX_POLL_TIMEOUT_MS) {\n            throw new IllegalArgumentException(\n                    \"Long Poll Timeout value cannot be more than 5 seconds\");\n        }\n        String queueName = QueueUtils.getQueueName(taskType, domain, null, null);\n\n        List<String> taskIds = new LinkedList<>();\n        List<Task> tasks = new LinkedList<>();\n        try {\n            taskIds = queueDAO.pop(queueName, count, timeoutInMilliSecond);\n        } catch (Exception e) {\n            LOGGER.error(\n                    \"Error polling for task: {} from worker: {} in domain: {}, count: {}\",\n                    taskType,\n                    workerId,\n                    domain,\n                    count,\n                    e);\n            Monitors.error(this.getClass().getCanonicalName(), \"taskPoll\");\n            Monitors.recordTaskPollError(taskType, domain, e.getClass().getSimpleName());","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/core/src/main/java/com/netflix/conductor/service/ExecutionService.java#L96-L132","documentation":"Thrown by ExecutionService.poll when the long-poll timeout parameter exceeds MAX_POLL_TIMEOUT_MS (5000 milliseconds / 5 seconds). Conductor caps long-poll duration at 5 seconds to prevent workers from holding connections open too long. This is an IllegalArgumentException returned as a 400 Bad Request from the REST/gRPC API.","triggerScenarios":"Calling the task poll API (GET /api/tasks/poll/{taskType} or /api/tasks/poll/batch/{taskType}) with a timeoutInMilliSecond query parameter greater than 5000. Also via the gRPC Poll endpoint with a timeout exceeding the cap. The constant MAX_POLL_TIMEOUT_MS is hardcoded at 5000 in both the REST and gRPC services.","commonSituations":"A worker SDK or custom client passes a large timeout value (e.g. 30000ms) expecting long-poll behavior similar to SQS. Copy-pasting a poll configuration from another system that allows 20-30 second long polls. Client-side default that was not adjusted to Conductor's 5-second cap.","solutions":["Set the poll timeout to 5000 milliseconds (5 seconds) or less in the worker/poll request.","If longer effective wait is needed, implement client-side retry loop: poll with 5s timeout, and if no task, poll again.","Update the worker SDK configuration to use a timeout within the 0–5000ms range."],"exampleFix":"// before — timeout too high\nGET /api/tasks/poll/batch/my_task?count=1&timeout=30000\n// 400: Long Poll Timeout value cannot be more than 5 seconds\n\n// after\nGET /api/tasks/poll/batch/my_task?count=1&timeout=5000","handlingStrategy":"validation","validationCode":"// Clamp poll timeout to the server max before sending the request\nprivate static final int MAX_POLL_TIMEOUT_MS = 5000;\n\nint safeTimeout = Math.min(requestedTimeoutMs, MAX_POLL_TIMEOUT_MS);\nList<Task> tasks = executionService.poll(taskType, workerId, count, safeTimeout);","typeGuard":"public static boolean isValidPollTimeout(int timeoutMs) {\n    return timeoutMs >= 0 && timeoutMs <= 5000;\n}","tryCatchPattern":null,"preventionTips":["Always cap poll timeout at 5000ms in worker SDK configuration.","For longer effective wait, implement a client-side poll loop with 5s individual timeouts.","Document the 5-second cap prominently in worker SDK docs."],"tags":["poll","task","timeout","validation","api"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}