Skip to content

Codex Desktop Windows: AttachConsole failed uncaught exception from node-pty conpty_console_list_agent when starting Run action #25372

Open

Description

@Hakuhonoo

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.

Activity

  1. added
    bugSomething isn't working
    appIssues related to the Codex desktop app
    windows-osIssues related to Codex on Windows systems
    on May 31, 2026
  2. tco1za commented on Jun 1, 2026

    @tco1za

    I can confirm this still reproduces on a similar setup.

    Environment:

    • Codex Desktop: 26.527.3686.0 (OpenAI.Codex_26.527.3686.0_x64__2p2nqsd0c76g0)
    • OS: Windows 11 Home x64, version 10.0.26200, build 26200
    • Local environment shell shown by Codex Run panel: Windows PowerShell

    Reproduction details:

    1. In a local workspace, .codex/environments/environment.toml has a Run action:
    [[actions]]
    name = "Run"
    icon = "run"
    command = "npm start"
    1. Clicking the Codex Desktop Run button executes the command in the integrated terminal. The terminal shows the npm script running successfully and returning to the prompt.
    2. A modal Electron dialog appears from Codex Desktop with:
    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\...: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)
    

    Additional notes:

    • The project command itself is not failing. Running the same npm start from an external shell does not show the dialog.
    • Even after changing the npm script to launch a GUI Electron app through a detached Node child process and then return immediately, Codex Desktop still shows the same AttachConsole failed modal.
    • The integrated terminal captured the successful output (Started ...) and returned to the PowerShell prompt before/while the Codex modal appeared.

    This seems consistent with the report here: the Codex Desktop Windows Run/integrated-terminal lifecycle is surfacing a non-fatal ConPTY/node-pty cleanup failure as an uncaught Electron main-process error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbugSomething isn't workingwindows-osIssues related to Codex on Windows systems

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions