codex - 💡(How to fix) Fix Windows Codex Desktop shows Electron "AttachConsole failed" dialog from node-pty conpty_console_list_agent

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…

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

Root Cause

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.

Fix Action

Fix / Workaround

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.

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

---

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);
RAW_BUFFERClick to expand / collapse

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.Codex reported package status Ok.
  • winget upgrade --name Codex did 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 3221225786 in an earlier session, but the visible dialog stack trace points specifically at the node-pty console process list helper.

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

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.

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 Windows Codex Desktop shows Electron "AttachConsole failed" dialog from node-pty conpty_console_list_agent