Skip to content

~40s hang on startup (Windows) #23207

Open

Description

@mrairdon-midmark

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

26.513.40821

What subscription do you have?

Enterprise

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What issue are you seeing?

Codex not responding for about 40s any time I start it.

2026-05-17_18-30-41-run-clock.mp4

What steps can reproduce the bug?

Start the app

What is the expected behavior?

It should let me use it in a reasonable amount of time after I open it.

Additional information

Agentic Analysis

Bug report: Codex Desktop locks up for ~42 seconds on cold launch (Windows)

Summary

On every cold launch of the Codex Desktop app on Windows, the UI is interactive but unresponsive — every renderer-to-backend RPC stalls for ~42 seconds before all completing simultaneously. Root cause is an unbounded Promise.all fan-out in the desktop's git-origins worker, which spawns ~3 × N git.exe processes (where N = recent workspaces). With Microsoft Defender real-time scan and Windows process-creation overhead, this dominates wall-clock time on launch and blocks the Electron main process's stdio reader, so unrelated backend RPCs queue behind it.

TL;DR

  • Observed: ~30–40 s "locked" feel on app start.
  • Measured: ~42 s RPC stall on every UI bootstrap call (config/read, account/read, skills/list, model/list, hooks/list, windowsSandbox/readiness, …).
  • Cause: worker.js w6() does Promise.all(dirs.map(...)) over recent workspaces, each triggering 3 git.exe spawns. ~24 git invocations race against Defender on cold start.
  • Side cause: heavy worker activity blocks the Electron main process's stdio pipe reader, causing apparently-unrelated backend RPC responses to queue.

Environment

Item Value
Codex Desktop 26.513.4821.0 (MSIX, installed at C:\Program Files\WindowsApps\OpenAI.Codex_26.513.4821.0_x64__<pkgid>\)
Bundled CLI (resources\codex.exe) 0.131.0-alpha.9 (per [AppServerConnection] Current reported app-server version)
Recent workspaces 8 (from globalState)
Repo dirs scanned 6 .git repos under a single workspace root + 2 non-repo dirs (a user Downloads folder, a subfolder of a repo)
OS Windows 11 Enterprise 10.0.26100
Git C:\Program Files\Git\cmd\git.exe (real .exe, not a .cmd shim)
Anti-malware Microsoft Defender (enterprise managed)
Shell PowerShell 7 (pwsh), profile on OneDrive
Remote SSH connections configured 5 (4 × remote SSH hosts, 1 × WSL)

Steps to reproduce

  1. Have a Codex Desktop install on Windows with several recent workspaces (≥ 4 git repos works).
  2. Close all Codex windows. Wait long enough that the b6 repo cache TTL (u6 = 24h) has expired — i.e. relaunching at least a day later, or after a reboot, or after killing all Codex.exe processes.
  3. Launch Codex. Time the period from app window appearance to UI becoming responsive (e.g., clicking the model picker returns data).

Expected: a few seconds.
Actual: ~30–45 seconds of unresponsiveness.

Evidence from logs

Logs in %LOCALAPPDATA%\Packages\OpenAI.Codex_<id>\LocalCache\Local\Codex\Logs\…\codex-desktop-<sessionGuid>-<pid>-tN-iN-HHMMSS-0.log.

Timeline of one cold launch (process start at 15:59:25.440)

t (s) Event
0.0 Launching app … platform=win32 packaged=true
5.1 warning Failed to load shell env caller=startup detail="Timed out after 5000ms."
7.1 [AppServerConnection] stdio_transport_spawned … codex.exe pid=30336
7.5 initialize_handshake_result durationMs=373 outcome=success (backend healthy)
8.6 [startup][renderer] app routes mounted after 8634ms (UI mounted)
13.5 First batch of backend RPCs return in ~3–4 s — normal.
~24 git-origins worker-complete dirCount=2 elapsedMs=1119 hostId=local originCount=2 (first batch of 2 dirs — fast)
~24 git-origins worker-complete dirCount=1 elapsedMs=1065 hostId=local originCount=1
66.3 git-origins worker-complete dirCount=8 elapsedMs=41981 hostId=local originCount=8 ← 42 s stall
~66 All pending RPCs return at once: config/read durationMs=45811, account/read durationMs=42737, skills/list durationMs=42745, model/list durationMs=42884, hooks/list durationMs=42736, windowsSandbox/readiness durationMs=42738, …

Notable: every blocked RPC completes within the same 30 ms window once the git scan finishes. This is the giveaway that they were queued in the Electron main process's stdio reader, not actually slow on the backend.

Sample log lines

2026-05-17T16:00:31.718Z info  [git] [git-origins] worker-complete dirCount=8 elapsedMs=41981 hostId=local originCount=8
2026-05-17T16:00:27.270Z info  [AppServerConnection] response_routed … durationMs=45811 method=config/read
2026-05-17T16:00:27.271Z info  [AppServerConnection] response_routed … durationMs=45789 method=experimentalFeature/enablement/set errorCode=-32600
2026-05-17T16:00:27.646Z info  [AppServerConnection] response_routed … durationMs=42737 method=account/read
2026-05-17T16:00:27.647Z info  [AppServerConnection] response_routed … durationMs=42745 method=skills/list
2026-05-17T16:00:27.648Z info  [AppServerConnection] response_routed … durationMs=42737 method=config/read
2026-05-17T16:00:27.649Z info  [AppServerConnection] response_routed … durationMs=42738 method=windowsSandbox/readiness
2026-05-17T16:00:27.649Z info  [AppServerConnection] response_routed … durationMs=42736 method=hooks/list
2026-05-17T16:00:27.668Z info  [AppServerConnection] response_routed … durationMs=42884 method=model/list
2026-05-17T15:59:44.902Z info  [electron-message-handler] Skills/list request cwdsCount=8 forceReload=false

The 8 cwds (extracted from ~/.codex/.codex-global-state.json, paths anonymized):

<workspaces>\repo-a                          (git)
<workspaces>\parent-repo\subdir              (no .git; subfolder of a repo)
<workspaces>\repo-b                          (git)
<workspaces>\repo-c                          (git)
<workspaces>\repo-d                          (git)
<workspaces>\repo-e                          (git)
<workspaces>\repo-f                          (git)
C:\Users\<user>\Downloads                    (no .git)

Root cause analysis

References below are to the formatted bundle from app.asar (resources\app.asar/.vite/build/worker.js and main-sqI8jfJr.js).

Call chain

  1. Renderer invalidates the git-origins React-Query key on active-workspace-roots-updated / workspace-root-options-updated events fired during launch.
  2. Main process IPC handler at main-sqI8jfJr.js:21042 — "git-origins": async ({ dirs, hostId }) => {…}. When the renderer passes no explicit dirs, it falls back to globalState recent workspaces (all 8). Forwards to the per-host worker via this.requestGitWorker({ method: 'git-origins', params: { dirs, … } }).
  3. Worker dispatcher at worker.js:59056 — case 'git-origins': calls j6(dirs, gitManager, signal) then emits the [git-origins] worker-complete log line with elapsedMs.
  4. j6 → M6 → w6 (worker.js:55787, 55790, 55756):
async function w6(e, t, n) {
  return Promise.all(
    e.map(async (e) => {
      try { return await T6(nW(e), t, n); }
      catch (t) { /* swallow, return null origin */ }
    }),
  );
}

This is the unbounded fan-out: no p-limit or semaphore. With 8 dirs that means 8 concurrent T6 chains.

  1. T6 (worker.js:55773) per-dir does:
let i = (await t.getWorktreeRepository(r, n))?.root ?? tW(e),
    a = await t.getRepoRepository(r, n),
    o = await a?.getOriginUrl(),
    s = a?.getCommonDir() ?? null;

Underneath this requires three git.exe invocations per dir:

  • git rev-parse --show-toplevel (via V2)
  • git rev-parse --git-dir (via H3)
  • git config --get remote.origin.url (via d6 at worker.js:55457, wrapping getOriginUrl at worker.js:55646)

Plus one where.exe invocation per worker lifetime to locate git.exe (worker.js:53633 I2(), result cached in A2).

  1. Actual spawn in $() at worker.js:53385 via S$({ args, cwd, env, … }).

Why this is so slow on Windows

Cost Approx
CreateProcess + git.exe + DLL load 80–150 ms
Defender real-time scan of git.exe 200–400 ms
git config + credential helper init 100–200 ms
.git/config + index read 50–150 ms
Per git.exe invocation ~400–800 ms

8 dirs × 3 spawns = 24 invocations. Even with Promise.all, Defender serializes scans of the same image, and process-creation contention dominates. Empirically: 42 s wall-clock for the batch on this user's machine.

Secondary failure mode: main process backpressure

The Electron main process is single-threaded JavaScript. While the worker child process is producing output (spawning gits, parsing remotes, emitting log events back to main), the main process event loop services that traffic and cannot drain the stdio response pipe from codex.exe (the Rust app-server). Therefore all backend responses queue in the kernel pipe buffer until the worker work clears. This is visible as:

durationMs=45811 method=config/read
durationMs=42738 method=windowsSandbox/readiness
durationMs=42745 method=skills/list
durationMs=42884 method=model/list

— all completing within the same millisecond window even though the backend almost certainly answered them in milliseconds.

Other issues spotted in the same log (lower priority)

1. PowerShell shell-env probe times out hard at 5 s

warning Failed to load shell env caller=startup detail="Timed out after 5000ms." durationMs=5085

PowerShell 7 cold-start on Windows with a typical enterprise profile (oh-my-posh, mise, etc.) commonly exceeds 5 s. Measured on this machine: pwsh -NoProfile ≈ 520 ms, pwsh with profile ≈ 3.6 s — but on a fully cold launch with OneDrive-hosted profile and Defender scanning, it can blow past 5 s. The 5 s cap means Codex falls back to a stripped PATH and user-installed tooling won't be found. Suggest:

  • Raise the cap to 10–15 s on Windows.
  • Or load the env asynchronously and fix up tools later when it arrives, rather than blocking the startup path on it.

2. Protocol drift between desktop and bundled CLI

error Request failed … error={"code":-32600,
  "message":"unsupported feature enablement `auth_elicitation`:
   currently supported features are apps, memories, mentions_v2, plugins,
   remote_control, tool_search, tool_suggest, tool_call_mcp_elicitation"}
  method=experimentalFeature/enablement/set

The desktop (26.513.4821.0) is requesting an experimental feature (auth_elicitation) that the bundled CLI (0.131.0-alpha.9) doesn't know about. Five such calls fail with errorCode=-32600. They don't cause the lockup (the failure is fast — only their response routing is delayed by the same queue), but they're noise that suggests the bundled CLI may be older than the desktop expects.

Suggested fixes (in priority order)

Primary

  1. Bound concurrency in w6's fan-out. Replace the bare Promise.all with a small concurrency limit (2–3). On Windows in particular, paralleling 24 process spawns gains very little because Defender scan-of-same-image serializes; meanwhile it starves the main process event loop. p-limit 2 should give nearly the same wall-clock with far less main-process pressure.

  2. Persist a (dir → originUrl, root, commonDir) cache to disk keyed by dir path and the mtime of .git/config. On cold launch, render recents from the disk cache and refresh in the background. The in-process memoize (maxAge: 24h at worker.js:55648) is useless across process restarts.

  3. Defer the entire git-origins scan until after first paint, or until the user opens the workspace picker. Recents can show their last known origin and refresh lazily.

  4. Filter the input list before scanning. Skip dirs that don't contain (or sit inside) a .git directory. The current input includes Downloads and a non-repo subfolder. Doing a cheap fs.access(dir/.git) first would let the scan early-exit on those without spawning git.

  5. Move backend stdio reads off the same loop slot as worker IPC. Either give the AppServer transport a dedicated IO thread/worker, or setImmediate-yield more aggressively while processing worker traffic, so other RPC traffic doesn't queue behind it. Even with (1)–(4), heavy workspaces will sometimes do real work; the desktop should not let that block all backend RPC traffic.

Secondary

  1. Increase the shell-env probe timeout on Windows to 10–15 s, or make it async and non-blocking on startup.

  2. Ship a matched desktop/CLI pair, or have the desktop gracefully no-op on features the CLI doesn't advertise (no errorCode=-32600).

Workarounds (user-side, until fixed)

  1. Defender process exclusion for git.exe and where.exe, and ideally the entire Codex install path. Single biggest knob on Windows.
  2. Trim recent workspaces to the 1–2 you actively use.
  3. Make sure git in PATH is a real .exe, not a chocolatey/scoop .cmd shim (otherwise worker.js:53627 P2() wraps every git call in cmd.exe /d /s /c).
  4. Shrink your PowerShell $PROFILE: lazy-load mise activate, oh-my-posh init, etc. Aim for < 2 s.
  5. Leave Codex running between sessions — getOriginUrl's 24 h in-process memoize keeps the cache warm and avoids the cold-launch scan.

Verifying a fix

A simple regression test would replay the same git-origins cold-launch shape:

// pseudo-test
const dirs = recentWorkspaces();        // 8+ Windows paths
const t0 = Date.now();
await scanGitOrigins(dirs);              // freshly seeded worker (no cache)
assert(Date.now() - t0 < 5000);          // budget: 5 s on Windows w/ Defender

Acceptance: cold scan of 8 dirs completes in < 5 s on a Windows machine with Microsoft Defender real-time scanning active and git.exe not on the exclusion list.

Artifacts available

  • Desktop logs: %LOCALAPPDATA%\Packages\OpenAI.Codex_<id>\LocalCache\Local\Codex\Logs\…
  • Global state: ~/.codex/.codex-global-state.json (contains recent workspaces)
  • Extracted+formatted bundle for code references (from app.asar):
    • .vite/build/worker.js
    • .vite/build/main-sqI8jfJr.js

Activity

  1. added
    app
    on May 17, 2026
  2. added
    bug
    windows-os
    app-server
    on May 17, 2026
  3. github-actions commented on May 17, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. adamgwinn commented on Jun 12, 2026

    @adamgwinn

    Possibly related data point from a separate Windows machine/workspace: I observed high-frequency git.exe spawning from Codex where the pathological command was hash-object --no-filters -- <path>, apparently over generated artifact files. Moving generated outputs into ignored _tmp/... folders plus a later Codex update appears to have stopped the hash-object storm in my monitor logs, while normal rev-parse / remote / status probes continue.

    I posted fuller details in #20567 because that issue is closer to the git.exe process storm symptom.

  5. aidawilliam41-ops commented on Sep 30, 2026

    @aidawilliam41-ops

    Related observation from one WPR-instrumented startup on the current Windows Store build. This does not reproduce the reported 40-second hang or establish the same root cause.

    Environment: Windows 11 Pro x64, build 26200; Store package 26.928.2636.0; frontend build 12404; local app-server reports 0.159.2. Recorded on 2026-09-30.

    Startup timing

    • Node performance time origin to sidebar_ready: 15.412 s.
    • OS ProcessCreate to emission of the successful app_start log event: 16.291 s. This is not an exact sidebar-ready timestamp.
    • The logged app_start duration of 10.033 s starts at the renderer/preload time origin; it excludes the preceding 5.380 s from Node origin to preload origin.

    Observed direct Git process starts

    These counts use individual ProcessStart events with the stable Desktop main process as the direct parent. Times are relative to OS ProcessCreate; counts are process launches, not concurrent processes or seconds spent waiting.

    Interval Direct git.exe starts Operations
    6–16 s 93 58 config, 34 rev-parse, 1 --version
    0–30 s 234 127 config, 101 rev-parse, 2 status, 1 each --version / remote / ls-files / for-each-ref

    Read-only inspection of the shipped bundle confirms relevant discovery paths: LOCAL_PROJECTS feeds git-origins from sidebar_workspace_groups; the Git worker resolves repository roots/common directories and reads remote.origin.url. A sidebar_task_pr_chip path also requests repository/PR metadata, including remote.upstream.url. We have not individually attributed all 234 launches to these callers.

    Measurement limits

    • ETW reports 312,805 lost events, so the trace is incomplete.
    • There are 51 reused process IDs elsewhere in the trace. The counts above use the parent and image from each direct ProcessStart, not a final descendant map.
    • CPU samples and disk operations do not establish CPU saturation, absence of all I/O delays, Defender involvement, or an exact critical path.
    • The recording overhead was not measured. This single launch does not establish a version regression.

    Could the team investigate repeated repository/PR discovery during startup, particularly caching, coalescing identical requests, and deferring metadata discovery until needed? This is a measured current-build data point, not a claim that any one proposed change will eliminate the delay.

    The separate caught attachment-cleanup error is tracked in #49419 and is not established as the cause here. Only sanitized aggregate observations are shared; no ETL, raw logs, account data, or private workspace paths are attached.

  6. James-Riordan commented on Dec 3, 2026

    @James-Riordan

    Current Windows reproduction: 116-folder Git-origin scan on launch, even with a flat sidebar

    I reproduced the same startup lookup pattern on Codex Desktop MSIX 26.1123.12889.0 on Windows 10 22H2 x64 (build 19045). Git for Windows installed on the machine reports 2.53.0.windows.3. This is a current-build data point about startup fan-out. I did not measure a 40-second RPC hang on this machine.

    Reproduction

    1. Have many local project folders registered in Codex.
    2. Set the Codex sidebar to a single chat list, fully exit the app, and reopen it normally.
    3. Observe the Git worker’s startup log and sample running Git processes during the first 40 seconds. No explicit Git operation or review was requested during this launch.

    Observed

    • A git-origins batch covered 116 folder paths, reported 28 origins, and took 5,896 ms. The 116-folder batch also appeared in the logs of the two preceding launch sessions.
    • The fresh-launch worker log had 25 Git-origin warnings tagged sidebar_workspace_groups or sidebar_workspace_task_groups_task_dirs. The logged commands include local git config --get remote.origin.url lookups. The single-list preference persisted across the restart.
    • During the 40-second window, 189 process samples observed a peak of 37 simultaneous Git processes and 71 distinct Git process IDs. These are host-wide sampled counts, not an exhaustive start trace. Some short-lived processes exited before their parent or command line could be read, so I cannot attribute every process to the sidebar worker. The burst cleared after startup.

    Requested behavior and regression check
    Render registered projects from saved state and defer origin lookup until a project or Git feature needs it. For any prefetch that remains, coalesce equivalent requests, reuse results across launches, and bound concurrent Git subprocesses. A useful Windows regression check would launch with 100+ registered folders in both sidebar modes and verify that the initial render does not initiate a full-folder origin sweep. Opening a project should still provide normal Git features.

    Only aggregate measurements and operation names are included here.

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

    appapp-serverbugperformancewindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions