{"record":{"id":"c2b5e91cde858dae","repo":"openai/codex","slug":"writer-already-taken","errorCode":null,"errorMessage":"writer already taken","messagePattern":"writer already taken","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/utils/pty/src/win/conpty.rs","lineNumber":181,"sourceCode":"    }\n\n    fn get_size(&self) -> Result<PtySize, Error> {\n        let inner = self.inner.lock().unwrap();\n        Ok(inner.size)\n    }\n\n    fn try_clone_reader(&self) -> anyhow::Result<Box<dyn std::io::Read + Send>> {\n        Ok(Box::new(self.inner.lock().unwrap().readable.try_clone()?))\n    }\n\n    fn take_writer(&self) -> anyhow::Result<Box<dyn std::io::Write + Send>> {\n        Ok(Box::new(\n            self.inner\n                .lock()\n                .unwrap()\n                .writable\n                .take()\n                .ok_or_else(|| anyhow::anyhow!(\"writer already taken\"))?,\n        ))\n    }\n}\n\nimpl SlavePty for ConPtySlavePty {\n    fn spawn_command(&self, cmd: CommandBuilder) -> anyhow::Result<Box<dyn Child + Send + Sync>> {\n        let inner = self.inner.lock().unwrap();\n        let child = inner.con.spawn_command(cmd)?;\n        Ok(Box::new(child))\n    }\n}\n","sourceCodeStart":163,"sourceCodeEnd":193,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/utils/pty/src/win/conpty.rs#L163-L193","documentation":"take_writer was called on a ConPTY master whose writable half has already been taken (Option::take consumed it). Only one writer can be extracted per PTY instance; a second call is a usage error.","triggerScenarios":"Thrown at codex-rs/utils/pty/src/win/conpty.rs:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reuse the writer handle obtained from the first take_writer call","Share or clone the existing writer instead of taking again","Restructure ownership so only one component takes the writer"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}