CLI /quit takes ~20s after shutdown UI due nested in-process app-server shutdown timeouts and OTEL metrics flush

Open 💬 1 comment Opened Jun 28, 2026 by KaminariOS

What version of Codex CLI is running?

codex-cli 0.142.0

What subscription do you have?

Pro lite

Which model were you using?

GPT-5.5

What platform is your computer?

Linux 6.18.33 x86_64 unknown

What terminal emulator and version are you using (if applicable)?

wezterm

Codex doctor report

{
  "schemaVersion": 1,
  "generatedAt": "1782664344s since unix epoch",
  "overallStatus": "fail",
  "codexVersion": "0.142.0",
  "checks": {
    "app_server.status": {
      "id": "app_server.status",
      "category": "app-server",
      "status": "ok",
      "summary": "background server is not running",
      "details": {
        "control socket": "/home/kosumi/.codex/app-server-control/app-server-control.sock",
        "daemon state dir": "/home/kosumi/.codex/app-server-daemon",
        "mode": "persistent",
        "pid file": "/home/kosumi/.codex/app-server-daemon/app-server.pid (missing)",
        "settings": "/home/kosumi/.codex/app-server-daemon/settings.json (file)",
        "status": "not running",
        "update-loop pid file": "/home/kosumi/.codex/app-server-daemon/app-server-updater.pid (file)"
      },
      "remediation": null,
      "durationMs": 0
    },
    "auth.credentials": {
      "id": "auth.credentials",
      "category": "auth",
      "status": "ok",
      "summary": "auth is configured",
      "details": {
        "auth file": "/home/kosumi/.codex/auth.json",
        "auth storage mode": "File",
        "stored API key": "false",
        "stored ChatGPT tokens": "true",
        "stored agent identity": "false",
        "stored auth mode": "chatgpt"
      },
      "remediation": null,
      "durationMs": 0
    },
    "config.load": {
      "id": "config.load",
      "category": "config",
      "status": "ok",
      "summary": "config loaded",
      "details": {
        "CODEX_HOME": "/home/kosumi/.codex",
        "config.toml": "/home/kosumi/.codex/config.toml",
        "config.toml parse": "ok",
        "cwd": "/home/kosumi",
        "enabled feature flags": "shell_tool, unified_exec, shell_snapshot, terminal_resize_reflow, sqlite, hooks, enable_request_compression, multi_agent, tool_suggest, in_app_browser, browser_use, browser_use_external, computer_use, plugin_sharing, image_generation, resize_all_images, skill_mcp_dependency_install, mentions_v2, steer, guardian_approval, goals, collaboration_modes, tool_call_mcp_elicitation, personality, fast_mode, tui_app_server, auto_compaction, remote_compaction_v2, workspace_dependencies",
        "feature flag overrides": "apps=false, plugins=false",
        "feature flags enabled": "29",
        "log dir": "/tmp/opencode/codex-logs",
        "mcp servers": "1",
        "model": "gpt-5.5",
        "model provider": "openai",
        "sqlite home": "/home/kosumi/.codex"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git version 2.54.0",
      "details": {
        ".git entry": "directory",
        "PATH git #1": "/home/kosumi/.nix-profile/bin/git",
        "PATH git entries": "1",
        "git build options": "git version 2.54.0; cpu: x86_64; no commit associated with this build; sizeof-long: 8; sizeof-size_t: 8; shell-path: /nix/store/gik3rh1vz2jlgnifb9dh6vc6sxwwz9jj-bash-5.3p9/bin/bash; rust: enabled; gettext: enabled; libcurl: 8.20.0; OpenSSL: OpenSSL 3.6.2 7 Apr 2026; zlib-ng: 2.3.3; SHA-1: SHA1_DC; SHA-256: SHA256_BLK; default-ref-format: files; default-hash: sha1",
        "git exec path": "/nix/store/bqz9b72r66apn6lrn5qxpklscld1mdik-git-with-svn-2.54.0/libexec/git-core",
        "git version": "git version 2.54.0",
        "repo detected": "true",
        "repo root": "/home/kosumi",
        "selected git": "/home/kosumi/.nix-profile/bin/git"
      },
      "remediation": null,
      "durationMs": 15
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "/home/kosumi/.nix-profile/bin/codex",
        "current executable": "/nix/store/s5rfjwqp1miwh2xkaip1l7iiwshhh6rr-codex-0.142.0/bin/codex-raw",
        "install context": "other",
        "managed by bun": "false",
        "managed by npm": "false",
        "managed package root": "not set"
      },
      "remediation": null,
      "durationMs": 0
    },
    "mcp.config": {
      "id": "mcp.config",
      "category": "mcp",
      "status": "ok",
      "summary": "MCP configuration is locally consistent",
      "details": {
        "configured servers": "1",
        "disabled servers": "1",
        "stdio servers": "1"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.env": {
      "id": "network.env",
      "category": "network",
      "status": "ok",
      "summary": "network-related environment looks readable",
      "details": {
        "proxy env vars": "none"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.provider_reachability": {
      "id": "network.provider_reachability",
      "category": "reachability",
      "status": "fail",
      "summary": "one or more required provider endpoints are unreachable over HTTP",
      "details": {
        "ChatGPT base URL": "https://chatgpt.com/backend-api/ request timed out (required)",
        "reachability mode": "ChatGPT auth"
      },
      "remediation": "Check proxy, VPN, firewall, DNS, and custom CA configuration.",
      "durationMs": 3015
    },
    "network.websocket_reachability": {
      "id": "network.websocket_reachability",
      "category": "websocket",
      "status": "ok",
      "summary": "Responses WebSocket handshake succeeded",
      "details": {
        "DNS": "2 IPv4, 2 IPv6, first IPv4",
        "auth mode": "chatgpt",
        "connect timeout": "15000 ms",
        "endpoint": "wss://chatgpt.com/backend-api/<redacted>",
        "handshake result": "HTTP 101 Switching Protocols",
        "model provider": "openai",
        "models etag present": "true",
        "provider name": "OpenAI",
        "proxy env vars": "none",
        "reasoning header": "false",
        "server model present": "false",
        "supports websockets": "true",
        "wire API": "responses"
      },
      "remediation": null,
      "durationMs": 1446
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running local build on linux-x86_64",
      "details": {
        "commit": "unknown",
        "current executable": "/nix/store/s5rfjwqp1miwh2xkaip1l7iiwshhh6rr-codex-0.142.0/bin/codex-raw",
        "install method": "other",
        "platform": "linux-x86_64",
        "version": "0.142.0"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search is OK (system)",
      "details": {
        "search command": "rg",
        "search command readiness": "ripgrep 15.1.0",
        "search provider": "system"
      },
      "remediation": null,
      "durationMs": 1
    },
    "sandbox.helpers": {
      "id": "sandbox.helpers",
      "category": "sandbox",
      "status": "ok",
      "summary": "sandbox configuration is readable",
      "details": {
        "approval policy": "OnRequest",
        "codex-linux-sandbox helper": "/home/kosumi/.codex/tmp/arg0/codex-arg0o5m7c1/codex-linux-sandbox",
        "execve wrapper helper": "/home/kosumi/.codex/tmp/arg0/codex-arg0o5m7c1/codex-execve-wrapper",
        "filesystem sandbox": "restricted",
        "network sandbox": "restricted"
      },
      "remediation": null,
      "durationMs": 0
    },
    "state.paths": {
      "id": "state.paths",
      "category": "state",
      "status": "ok",
      "summary": "state paths and databases are inspectable",
      "details": {
        "CODEX_HOME": "/home/kosumi/.codex (dir)",
        "active rollout files": "4764 files, 1259616463 total bytes, 264403 average bytes",
        "archived rollout files": "0 files, 0 total bytes, 0 average bytes",
        "goals DB": "/home/kosumi/.codex/goals_1.sqlite (file)",
        "goals DB integrity": "ok",
        "log DB": "/home/kosumi/.codex/logs_2.sqlite (file)",
        "log DB integrity": "ok",
        "log dir": "/tmp/opencode/codex-logs (dir)",
        "memories DB": "/home/kosumi/.codex/memories_1.sqlite (file)",
        "memories DB integrity": "ok",
        "sqlite home": "/home/kosumi/.codex (dir)",
        "state DB": "/home/kosumi/.codex/state_5.sqlite (file)",
        "state DB integrity": "ok"
      },
      "remediation": null,
      "durationMs": 386
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "ok",
      "summary": "rollout files and state DB thread inventory agree",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "4764",
        "rollout DB active rows": "4764",
        "rollout DB archive mismatches": "0",
        "rollout DB archived files": "0",
        "rollout DB archived rows": "0",
        "rollout DB duplicate DB paths": "0",
        "rollout DB duplicate rollout thread ids": "0",
        "rollout DB malformed file names": "0",
        "rollout DB missing active rows": "0",
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "openai=4764",
        "rollout DB rows": "4764",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "exec=3311, cli=1276, vscode=157, mcp=11, subagent:review=5, subagent:thread_spawn=4",
        "rollout DB stale rows": "0"
      },
      "remediation": null,
      "durationMs": 22561
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language en-US",
      "details": {
        "EDITOR": "set",
        "LANG": "en_US.UTF-8",
        "PAGER": "set",
        "VISUAL": "not set",
        "os": "NixOS 26.11.0 [64-bit]",
        "os language": "en-US",
        "os type": "NixOS",
        "os version": "26.11.0"
      },
      "remediation": null,
      "durationMs": 0
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "fail",
      "summary": "TERMINFO unreadable - terminal capabilities are unknown",
      "details": {
        "COLORTERM": "truecolor",
        "DISPLAY": "present",
        "TERMINFO_DIRS entry": [
          "/home/kosumi/.nix-profile/share/terminfo (dir)",
          "/nix/profile/share/terminfo (missing)",
          "/home/kosumi/.local/state/nix/profile/share/terminfo (missing)",
          "/etc/profiles/per-user/kosumi/share/terminfo (missing)",
          "/nix/var/nix/profiles/default/share/terminfo (missing)",
          "/run/current-system/sw/share/terminfo (dir)"
        ],
        "TERM_PROGRAM": "WezTerm",
        "WAYLAND_DISPLAY": "present",
        "color output": "enabled",
        "effective locale": "en_US.UTF-8",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout is terminal": "true",
        "terminal": "WezTerm",
        "terminal size": "157x42",
        "terminal version": "0-unstable-2026-03-31"
      },
      "issues": [
        {
          "severity": "fail",
          "cause": "TERMINFO unreadable - terminal capabilities are unknown",
          "measured": null,
          "expected": "readable terminfo file or directory",
          "remedy": "check that $TERMINFO points to a readable directory",
          "fields": [
            "TERMINFO",
            "TERMINFO_DIRS entry"
          ]
        }
      ],
      "remediation": null,
      "durationMs": 0
    },
    "terminal.title": {
      "id": "terminal.title",
      "category": "title",
      "status": "ok",
      "summary": "terminal title default",
      "details": {
        "terminal title activity": "true",
        "terminal title items": "activity, project-name",
        "terminal title project source": "git repo root",
        "terminal title project value": "kosumi",
        "terminal title source": "default"
      },
      "remediation": null,
      "durationMs": 0
    },
    "updates.status": {
      "id": "updates.status",
      "category": "updates",
      "status": "ok",
      "summary": "update configuration is locally consistent",
      "details": {
        "cached latest version": "0.142.3",
        "check for update on startup": "false",
        "dismissed version": "0.135.0",
        "last checked at": "2026-06-27T16:07:48.836062088Z",
        "latest version": "0.142.3",
        "latest version status": "newer version is available",
        "update action": "manual or unknown",
        "version cache": "/home/kosumi/.codex/version.json"
      },
      "remediation": null,
      "durationMs": 1727
    }
  }
}

What issue are you seeing?

In the Codex CLI TUI, /quit is accepted quickly and the shutdown UI paints almost immediately, but the process stays alive for about 20 seconds before the terminal returns.

This is not just terminal/pane detection. A real WezTerm pane harness that records the Codex PID shows the Codex process itself exits after ~20s.

Local mitigation:

[otel]
metrics_exporter = "none"
reduces the delay from ~20s to 10s, so roughly half of the delay is OTEL/Statsig metrics shutdown. The remaining 10s appears to be nested in-process app-server shutdown fallback waits.

What steps can reproduce the bug?

  1. Run Codex CLI TUI in a real terminal.
  2. Wait until the initial model/session UI has loaded.
  3. Type /quit and press Enter.
  4. Observe that the shutdown UI appears quickly, but the process exits much later.

Measured locally with Codex 0.142.0:

default release config

shutdown_paint_ms=377 process_exit_ms=20296 pane_exit_ms=20296
shutdown_paint_ms=846 process_exit_ms=20695 pane_exit_ms=20695

with [otel] metrics_exporter = "none"

shutdown_paint_ms=377 process_exit_ms=10260 pane_exit_ms=10260
shutdown_paint_ms=395 pane_exit_ms=10181

What is the expected behavior?

After /quit is accepted and the shutdown UI is painted, the CLI should exit promptly.
If graceful app-server/thread/telemetry cleanup cannot complete quickly, it should be timeout-isolated or detached so a user-initiated quit does not wait ~10-20 seconds.

Additional information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗