Windows Codex Desktop shows Electron "AttachConsole failed" dialog from node-pty conpty_console_list_agent
What happened?
Codex Desktop on Windows can show a modal Electron error dialog:
A JavaScript error occurred in the main process
Uncaught Exception:
Error: AttachConsole failed
at Object.<anonymous> (C:\Program Files\WindowsApps\OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0\app\resources\app.asar.unpacked\node_modules\node-pty\lib\conpty_console_list_agent.js:26)
at Module._compile (node:internal/modules/cjs/loader:1820:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1953:10)
at Module.load (node:internal/modules/cjs/loader:1540:32)
at Module._load (node:internal/modules/cjs/loader:1342:12)
at c._load (node:electron/js2c/node_init:2:18082)
at wrapModuleLoad (node:internal/modules/cjs/loader:262:19)
at loadCJSModuleWithModuleLoad (node:internal/modules/esm/translators:334:3)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:235:7)
at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
The main Codex window may continue running, but the error dialog appears as a main-process JavaScript exception.
Environment
- OS: Windows, locale zh-CN
- Codex Desktop package:
OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0 - Codex app version reported by Windows Appx:
26.527.3686.0 - Installed from: Microsoft Store / WindowsApps package
- Shell environment observed in the session:
SHELL=C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe,ComSpec=C:\WINDOWS\system32\cmd.exe
Local investigation
The thrown string appears in the unpacked node-pty helper:
C:\Program Files\WindowsApps\OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0\app\resources\app.asar.unpacked\node_modules\node-pty\lib\conpty_console_list_agent.js
That helper currently does roughly:
var getConsoleProcessList = utils_1.loadNativeModule('conpty_console_list').module.getConsoleProcessList;
var shellPid = parseInt(process.argv[2], 10);
var consoleProcessList = getConsoleProcessList(shellPid);
process.send({ consoleProcessList: consoleProcessList });
process.exit(0);
windowsPtyAgent.js calls this helper from _getConsoleProcessList() while killing/cleaning up a ConPTY-backed terminal session. It already has a timeout fallback to return [innerPid], but the forked helper can throw AttachConsole failed before sending a message. Because the child process is Electron/Node, the uncaught exception is surfaced as a modal main-process JavaScript error dialog instead of being treated as a best-effort cleanup failure.
A local hotfix would likely be to make conpty_console_list_agent.js catch failures from getConsoleProcessList(shellPid) and send a fallback list, for example [shellPid], or to make the parent handle child process error/exit without surfacing this as an Electron dialog. The WindowsApps package is not user-writable, so this could not be patched locally without taking ownership/modifying packaged app files.
Expected behavior
Failure to attach to a console while enumerating processes during terminal cleanup should be non-fatal. Codex should continue without showing a main-process JavaScript exception dialog.
Actual behavior
A modal Electron error dialog is shown with Error: AttachConsole failed from node-pty/lib/conpty_console_list_agent.js.
Additional notes
Get-AppxPackage OpenAI.Codexreported package statusOk.winget upgrade --name Codexdid not find a newer version at the time of testing.- Current Codex logs did not show
AttachConsole failed; the exception appears to happen in the early/forked helper path before normal app logging captures it. - A separate local log showed an app-server exit code
3221225786in an earlier session, but the visible dialog stack trace points specifically at the node-pty console process list helper.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗