Skip to content

[Windows Desktop] electron-sampler retries failing Win32_Process snapshots indefinitely and can cause process buildup #34580

Description

@yokelyangzhe

Codex version

Windows Store desktop app 26.715.8383.0

Platform

Windows x64, build 10.0.19044

What issue are you seeing?

The Windows desktop app's electron-sampler repeatedly launches this PowerShell command and logs a failure:

$ErrorActionPreference = 'Stop'; Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId | ConvertTo-Json -Depth 2

The retry has no effective single-flight/backoff behavior. In a clean desktop session it recurs roughly every 10–20 seconds. During longer Agent/browser workloads, PowerShell/browser/cleanup children can accumulate until process queries slow down and the machine runs out of usable memory.

A representative warning is:

warning [electron-sampler] Failed to collect child process snapshot errorMessage="Command failed: powershell.exe -NoProfile -NonInteractive -Command ... Get-CimInstance Win32_Process ... ConvertTo-Json -Depth 2"

Steps to reproduce

  1. Launch the Microsoft Store Codex desktop app on Windows.
  2. Run a local Agent task (browser/Playwright work makes the impact easier to observe, but the sampler failure also occurs while otherwise idle).
  3. Inspect %LOCALAPPDATA%\Codex\Logs\...\codex-desktop-*-t0-*.log.
  4. Observe repeated electron-sampler child-process snapshot failures.
  5. With a longer browser task, observe increasing PowerShell/browser/cleanup process pressure and eventually severe UI/memory degradation.

Diagnostics already performed

  • powershell.exe exists and resolves from PATH; current-session ENOENT count is 0.
  • PowerShell profiles are absent, so this is not a profile loop.
  • winmgmt is running and the WMI repository reports consistent.
  • The exact full snapshot command succeeds with EXIT=0 from an elevated command prompt.
  • From a standard-user prompt, Get-CimInstance Win32_Process -ErrorAction Stop succeeds and returned 473 rows.
  • The standard-user full Select/ConvertTo-Json pipeline returned exit code 1 with no stderr.
  • The packaged desktop app still retries the failed command: a fresh session logged 8 failures in about 85 seconds, then continued increasing.
  • A clean session had 0 taskkill and 0 conhost log references initially; those are observed only after heavier timed-out Agent/browser activity.
  • During a previous failure storm, WMI Operational event 5858 reported 0x80041032 with Throttling Idle/stack Tasks in hitting Max Memory quota for repeated Win32_Process queries.
  • The issue persisted across Windows restarts and Codex desktop restarts.

Expected behavior

The desktop app should collect the process snapshot successfully in its packaged/non-elevated context. If collection fails, it should be single-flight, use bounded exponential backoff, and ensure the exact child process is closed before retrying. Ideally this process-tree sampling should use a native Windows API rather than repeatedly spawning PowerShell/WMI.

Additional context

Issue #24913 contains the same electron-sampler warning in a different Windows desktop failure, and #17208 reports repeated PowerShell launches in the IDE extension. This report is focused specifically on the desktop sampler retry/process-buildup loop.

No project source, prompts, credentials, or private workspace data are included here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbugSomething isn't workingperformancewindows-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