Windows: closing a Claude Code session triggers uncaught "AttachConsole failed" error in Codex App

Open 💬 2 comments Opened May 31, 2026 by Lesterffx
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the Codex App are you using (From “About Codex” dialog)?

26.527.3686.0

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

After opening Claude Code inside the Codex App and then closing it, Codex shows a Windows/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\re...: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 app appears to continue running afterward, but the uncaught exception dialog is shown.

A screenshot of the error dialog was provided in the Codex conversation and can be used as visual evidence

What steps can reproduce the bug?

  1. Open Codex App on Windows.
  2. Start or open Claude Code from inside Codex.
  3. Close the Claude Code session/window.
  4. Observe that Codex shows an Electron main-process JavaScript error dialog with:

Error: AttachConsole failed

Feedback ID:
019e7e34-060c-7a70-ae0f-4214841cee20

What is the expected behavior?

Closing a Claude Code session should not show an uncaught JavaScript error dialog.

If terminal cleanup or process cleanup fails on Windows, Codex should handle the error gracefully and continue without surfacing an Electron main-process exception to the user.

Additional information

Local investigation suggests this may be related to Codex's bundled node-pty Windows ConPTY cleanup path, rather than Claude Code itself.

Evidence observed locally:

  • The exact string "AttachConsole failed" exists in Codex's bundled node-pty native 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

  • node-pty's Windows cleanup code calls/forks conpty_console_list_agent to fetch console process lists during pty cleanup.
  • Codex logs around the incident show:
  • shutdown around 2026-05-31 21:18 local time
  • external agent import activity for providerId=claude-code shortly after
  • no matching Windows Application Event Log crash entry was found in the same time window

There are also repeated plugin cache warnings in Codex logs:
plugin_cache_windows_file_lock / failed to back up plugin cache entry / os error 5

Those warnings may be unrelated, but they were present in the same log file.

View original on GitHub ↗

2 Comments

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #25272
  • #25175
  • #25372
  • #25325
  • #25225

Powered by Codex Action

starim00 · 2 months ago

Adding another reproduction from the same Windows build/package, with a slightly different trigger.

Observed trigger:

  • OpenAI Codex App on Windows.
  • Close the Codex bottom-bar / bottom dock window.
  • A modal Electron dialog appears:
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\re...: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)

Environment from the affected machine:

  • Codex App package: OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0
  • Codex App version: 26.527.3686.0
  • CLI visible on PATH: codex-cli 0.133.0
  • OS: Microsoft Windows NT 10.0.26200.0, Windows 11 Enterprise x64, build 26200

Local evidence:

  • The app logs around the close path show browser/sidebar teardown before the app-server transport stops, e.g. browser-sidebar-manager reports IAB_LIFECYCLE route window is not live, then closed browser sidebar page, then Stopping app-server transport.
  • I could not find a matching Windows Application Event Log crash entry for Codex; this appears to be an Electron uncaught JS/native-module exception dialog, not a normal WER app crash.
  • The exact AttachConsole failed string is present in the bundled node-pty native module at:

app.asar.unpacked\node_modules\node-pty\build\Release\conpty_console_list.node

  • The unguarded JS caller is still:

node_modules\node-pty\lib\conpty_console_list_agent.js, where getConsoleProcessList(shellPid) is called without a try/catch fallback.

This looks consistent with the issue description here: a PTY cleanup / console process-list lookup failure during window/session teardown bubbles out as a user-visible Electron main-process error. A defensive fallback in conpty_console_list_agent or in the caller that treats AttachConsole failed like the existing timeout fallback would likely avoid the modal dialog.