{"record":{"id":"5841f259b50ceba6","repo":"gradle/gradle","slug":"could-not-forward-client-stdin","errorCode":null,"errorMessage":"Could not forward client stdin.","messagePattern":"Could not forward client stdin\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"platforms/core-runtime/launcher/src/main/java/org/gradle/launcher/daemon/server/DefaultDaemonConnection.java","lineNumber":308,"sourceCode":"    private static class StdinQueue extends CommandQueue<InputMessage, StdinHandler> {\n\n        private StdinQueue(ExecutorFactory executorFactory) {\n            super(executorFactory, \"Stdin handler\");\n        }\n\n        @Override\n        protected boolean doHandleCommand(final StdinHandler handler, InputMessage command) {\n            try {\n                if (command instanceof CloseInput) {\n                    handler.onEndOfInput();\n                    return true;\n                } else if (command instanceof UserResponse) {\n                    handler.onUserResponse((UserResponse) command);\n                } else {\n                    handler.onInput((ForwardInput) command);\n                }\n            } catch (Exception e) {\n                LOGGER.warn(\"Could not forward client stdin.\", e);\n                return true;\n            }\n            return false;\n        }\n\n        @Override\n        protected void doHandleDisconnect() {\n            queue.clear();\n            queue.add(new CloseInput());\n        }\n    }\n\n    private static class CancelQueue extends CommandQueue<Cancel, Runnable> {\n\n        private CancelQueue(ExecutorFactory executorFactory) {\n            super(executorFactory, \"Cancel handler\");\n        }\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/core-runtime/launcher/src/main/java/org/gradle/launcher/daemon/server/DefaultDaemonConnection.java#L290-L326","documentation":"The daemon multiplexes the client's stdin over the connection as ForwardInput/CloseInput/UserResponse commands and dispatches them to the build's StdinHandler inside a command queue. If handler.onInput(...), handler.onEndOfInput(), or handler.onUserResponse(...) throws, the exception is caught, this warning is logged, and the queue moves on (returns true, command consumed).","triggerScenarios":"A stdin command arrives but the build-side stdin handler fails - build input stream already closed, console/encoding errors, or an interactive build that finished while further stdin commands were still queued.","commonSituations":"Piping stdin into a Gradle build that prompts interactively while running in the daemon; CI jobs with closed stdin; pressing Ctrl+C during an interactive prompt; tools streaming input to 'gradle' after the build completed.","solutions":["Check the attached exception - if the build was already aborting or finished, the warning is harmless","Do not feed stdin to non-interactive/daemon builds; use -q, --console=plain, or close the pipe","For prompts, prefer passing answers via properties or a file instead of live stdin through the daemon","Re-run the build - stdin forwarding state is per-connection and resets"],"exampleFix":"# before: CI pipes stdin into a daemon build that never reads it\ncat answers.txt | ./gradlew ask\n\n# after: pass answers as a property, keep stdin closed\n./gradlew ask -PanswersFile=answers.txt < /dev/null","handlingStrategy":"validation","validationCode":"// only forward stdin for builds that actually read it\nboolean buildReadsStdin = Boolean.getBoolean(\"mybuild.interactive\");\nif (!buildReadsStdin) System.in.close(); // daemon gets no stdin to mis-forward","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Redirect stdin from /dev/null for non-interactive daemon builds ('< /dev/null')","Pass interactive answers via -P properties or files instead of piping them through the daemon","Remember stdin handling is per-client-connection; a fresh build resets it"],"tags":["gradle","daemon","stdin","console"],"backgroundTag":"stdin-forwarding-failed","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}