{"record":{"id":"31b2e81eb6dd15a2","repo":"openai/codex","slug":"failed-to-resize-console-to-x-hresult","errorCode":null,"errorMessage":"failed to resize console to {}x{}: HRESULT: {}","messagePattern":"failed to resize console to (.+?)x(.+?): HRESULT: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/utils/pty/src/win/psuedocon.rs","lineNumber":156,"sourceCode":"                output.as_raw_handle() as _,\n                PSEUDOCONSOLE_RESIZE_QUIRK,\n                &mut con,\n            )\n        };\n        ensure!(\n            result == S_OK,\n            \"failed to create psuedo console: HRESULT {result}\"\n        );\n        Ok(Self {\n            con,\n            _input: input,\n            _output: output,\n        })\n    }\n\n    pub fn resize(&self, size: COORD) -> Result<(), Error> {\n        let result = unsafe { (CONPTY.ResizePseudoConsole)(self.con, size) };\n        ensure!(\n            result == S_OK,\n            \"failed to resize console to {}x{}: HRESULT: {}\",\n            size.X,\n            size.Y,\n            result\n        );\n        Ok(())\n    }\n\n    pub fn spawn_command(&self, cmd: CommandBuilder) -> anyhow::Result<WinChild> {\n        let job = Arc::new(JobObject::create()?);\n        let mut si: STARTUPINFOEXW = unsafe { mem::zeroed() };\n        si.StartupInfo.cb = mem::size_of::<STARTUPINFOEXW>() as u32;\n        si.StartupInfo.dwFlags = STARTF_USESTDHANDLES;\n        si.StartupInfo.hStdInput = INVALID_HANDLE_VALUE;\n        si.StartupInfo.hStdOutput = INVALID_HANDLE_VALUE;\n        si.StartupInfo.hStdError = INVALID_HANDLE_VALUE;\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/utils/pty/src/win/psuedocon.rs#L138-L174","documentation":"Fires when ResizePseudoConsole returns a non-S_OK HRESULT inside ConPTY::resize, meaning the Windows pseudoconsole could not be resized to the requested COORD dimensions. This typically happens if the console handle is invalid/closed or the OS rejects the size.","triggerScenarios":"Thrown at codex-rs/utils/pty/src/win/psuedocon.rs:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the HPCON handle is still valid and the pseudoconsole has not been closed before resizing","Check the HRESULT code (e.g. E_HANDLE, E_INVALIDARG) to identify the underlying Win32 failure","Ensure the requested COORD width/height are sane (non-zero, within limits)","Log the error and continue if a failed resize is non-fatal for the caller"],"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"}