codex - 💡(How to fix) Fix Codex Desktop Windows: `AttachConsole failed` uncaught exception from node-pty `conpty_console_list_agent` when starting Run action

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

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.

Error Message

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) ...

Root Cause

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.

Code Example

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)
    ...

---

[[actions]]
name = "Run"
icon = "run"
command = "./run"

---

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

---

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

---

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);

---

var agent = child_process_1.fork(path.join(__dirname, 'conpty_console_list_agent'), [_this._innerPid.toString()]);

---

let consoleProcessList;
try {
  consoleProcessList = getConsoleProcessList(shellPid);
} catch {
  consoleProcessList = [shellPid];
}
process.send({ consoleProcessList });
process.exit(0);
RAW_BUFFERClick to expand / collapse

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, build 26200
  • 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:

  1. Open Codex Desktop on Windows.
  2. Open a local workspace that has a .codex/environments/environment.toml Run action, for example:
[[actions]]
name = "Run"
icon = "run"
command = "./run"
  1. The Run action invokes a local batch/script that starts a GUI app process and exits/returns quickly.
  2. Click the Run action in Codex Desktop.
  3. The JavaScript error dialog appears with Error: AttachConsole failed.
  4. 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.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

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);

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex Desktop Windows: `AttachConsole failed` uncaught exception from node-pty `conpty_console_list_agent` when starting Run action