Codex Desktop Windows: `AttachConsole failed` uncaught exception from node-pty `conpty_console_list_agent` when starting Run action
Summary
Codex Desktop on Windows shows an Electron main-process JavaScript error dialog when starting a project Run action. The Run action still proceeds afterward, but Codex briefly loses/closes the active chat/session UI and then launches the target app.
The failure appears to be inside Codex Desktop's bundled node-pty ConPTY cleanup path, not inside the user's project command.
Environment
- OS: Windows 11 Pro x64, version
10.0.26200, build26200 - Codex Desktop install/package observed:
OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0 - Install type/path shape: Microsoft Store / MSIX, under
C:\Program Files\WindowsApps\OpenAI.Codex_<version>_x64__2p2nqsd0c76g0\app\ - Shell used by Codex/tooling: PowerShell 7 / Windows PowerShell processes are present under the Codex Desktop process tree
User-visible error
When clicking Run in Codex Desktop, Windows shows a modal 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\...)
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)
...
Reproduction pattern
Observed consistently after restarting both Windows and Codex Desktop:
- Open Codex Desktop on Windows.
- Open a local workspace that has a
.codex/environments/environment.tomlRun action, for example:
[[actions]]
name = "Run"
icon = "run"
command = "./run"
- The Run action invokes a local batch/script that starts a GUI app process and exits/returns quickly.
- Click the
Runaction in Codex Desktop. - The JavaScript error dialog appears with
Error: AttachConsole failed. - After dismissing the dialog, the target app still starts and works normally.
Running the same script manually from an external shell does not show the error.
Local investigation
The exact AttachConsole failed string was found in Codex Desktop's bundled native node-pty module:
C:\Program Files\WindowsApps\OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0\app\resources\app.asar.unpacked\node_modules\node-pty\build\Release\conpty_console_list.node
The JavaScript agent that calls this native module is:
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
Relevant code in conpty_console_list_agent.js:
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);
The call to getConsoleProcessList(shellPid) is not wrapped in try/catch, so when the native module throws Error: AttachConsole failed, the forked Electron/Node process surfaces it as a user-visible "JavaScript error occurred in the main process" dialog.
The agent is spawned by node-pty/lib/windowsPtyAgent.js during ConPTY kill/cleanup:
var agent = child_process_1.fork(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()]);
There is a timeout fallback to [_this._innerPid], but no error/uncaught-exception fallback for the forked conpty_console_list_agent process itself. Since child_process.fork() uses the Electron/Codex runtime, the uncaught exception becomes a visible Codex Desktop error dialog.
Expected behavior
Codex Desktop should not show an uncaught main-process JavaScript error dialog when ConPTY console process-list discovery fails during PTY cleanup.
A safe fallback would be to catch getConsoleProcessList(shellPid) failures and return [shellPid], matching the existing timeout fallback behavior.
Example defensive behavior:
let consoleProcessList;
try {
consoleProcessList = getConsoleProcessList(shellPid);
} catch {
consoleProcessList = [shellPid];
}
process.send({ consoleProcessList });
process.exit(0);
Impact
- The Run action still launches the target app, so this is not a project startup failure.
- The modal error is shown every time for the affected setup.
- The active Codex chat/session UI may close or detach during this flow before the target app launches.
- The error appears to be a Codex Desktop/node-pty Windows ConPTY cleanup bug rather than a problem in the workspace command.
Privacy note
This report intentionally omits project names, usernames, and workspace paths. Paths above are limited to the public Codex package path/version and sanitized Windows install locations.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗