codex - 💡(How to fix) Fix Regression: Playwright MCP stdio processes still leak after #16895 fix — 213 orphaned pairs, 13.6 GB RSS [3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#17832Fetched 2026-04-15 06:27:28
View on GitHub
Comments
3
Participants
2
Timeline
18
Reactions
0
Timeline (top)
labeled ×5cross-referenced ×4commented ×3unlabeled ×3

Issue #16895 (stdio MCP child processes not cleaned up) was closed on April 9 as fixed. As of April 14 on codex-cli 0.120.0, the bug is still present — specifically for @playwright/mcp configured as a global stdio MCP server in config.toml.

After a normal day of use in Codex Desktop involving multi-agent / subagent workflows, 213 leaked npm exec @playwright/mcp@latest + node playwright-mcp process pairs accumulated under the codex app-server process tree, consuming 13.6 GB of RSS and contributing to Activity Monitor reporting ~24 GB total for Codex.

This is the same root cause as #17574 (xcodebuild/chrome-devtools MCP leak) and #12491 (original 37 GB / 1300+ zombie report). The lifecycle fix from #16895 did not fully resolve the problem — subagent thread teardown still does not reap MCP child processes.

Root Cause

This is the same root cause as #17574 (xcodebuild/chrome-devtools MCP leak) and #12491 (original 37 GB / 1300+ zombie report). The lifecycle fix from #16895 did not fully resolve the problem — subagent thread teardown still does not reap MCP child processes.

Fix Action

Fix / Workaround

Immediate workaround

Code Example

codex app-server (PID 4938, 993.8 MB physical footprint)
├── 213 × npm exec @playwright/mcp@latest  (~35 MB each = 7.4 GB)
│   └── each spawns: node playwright-mcp   (~30 MB each = 6.2 GB)
└── (total leaked MCP processes: 426, total leaked RSS: 13.6 GB)

---

DefaultMallocZone: 179.3 MB resident + 792.5 MB swapped
                   5,023,995 allocations, 880.6 MB allocated
                   335.8 MB stack across 61 threads

---

pkill -f "playwright-mcp"
pkill -f "npm exec @playwright/mcp"
RAW_BUFFERClick to expand / collapse

Regression: Playwright MCP stdio processes still leak after #16895 fix — 213 orphaned pairs, 13.6 GB RSS

Environment

FieldValue
Codex CLIcodex-cli 0.120.0
Codex App26.409.20454
SubscriptionChatGPT Pro
PlatformmacOS 26.4.1 (25E253), Apple M3 Pro, 36 GB RAM
MCP server@playwright/mcp@latest (stdio transport)

Summary

Issue #16895 (stdio MCP child processes not cleaned up) was closed on April 9 as fixed. As of April 14 on codex-cli 0.120.0, the bug is still present — specifically for @playwright/mcp configured as a global stdio MCP server in config.toml.

After a normal day of use in Codex Desktop involving multi-agent / subagent workflows, 213 leaked npm exec @playwright/mcp@latest + node playwright-mcp process pairs accumulated under the codex app-server process tree, consuming 13.6 GB of RSS and contributing to Activity Monitor reporting ~24 GB total for Codex.

This is the same root cause as #17574 (xcodebuild/chrome-devtools MCP leak) and #12491 (original 37 GB / 1300+ zombie report). The lifecycle fix from #16895 did not fully resolve the problem — subagent thread teardown still does not reap MCP child processes.

Forensic data

Process tree before cleanup

codex app-server (PID 4938, 993.8 MB physical footprint)
├── 213 × npm exec @playwright/mcp@latest  (~35 MB each = 7.4 GB)
│   └── each spawns: node playwright-mcp   (~30 MB each = 6.2 GB)
└── (total leaked MCP processes: 426, total leaked RSS: 13.6 GB)

Memory breakdown (physical footprint via vmmap)

ProcessPIDsPhysical Footprint
Codex main (Electron)4892177.0 MB
codex app-server (Rust)4938993.8 MB
Renderer #14950560.2 MB
Renderer #25676134.5 MB
Renderer #35729134.7 MB
GPU process4895514.6 MB
Network service489716.3 MB
Tracing service6165851.3 MB
213 × npm exec playwrightvarious7,550 MB (7.4 GB)
213 × node playwright-mcpvarious6,304 MB (6.2 GB)
Grand total433 processes~15.3 GB RSS

app-server malloc analysis (PID 4938)

DefaultMallocZone: 179.3 MB resident + 792.5 MB swapped
                   5,023,995 allocations, 880.6 MB allocated
                   335.8 MB stack across 61 threads

The app-server itself has ~5M live allocations and 792 MB swapped out — likely holding session state / MCP connection metadata for all 213 leaked connections.

Reproduction context

  • config.toml has @playwright/mcp@latest as a global stdio MCP server
  • Normal usage pattern: Codex Desktop with multi-agent workflows (max_threads = 20, max_depth = 2)
  • 927 total threads in state_5.sqlite, 476 spawn edges
  • Heavy subagent use: one parent thread spawned 58 children, another 37
  • Each subagent session appears to spawnsession_initmcp_manager_init → spawn new MCP processes
  • When the subagent session closes, the MCP processes are not terminated

Log evidence from logs_2.sqlite

The codex_core::spawn and codex_mcp::mcp_connection_manager modules show the pattern:

  1. thread_spawn creates a new subagent session
  2. session_initmcp_manager_init starts fresh MCP connections (including Playwright)
  3. Session completes and thread is marked closed in thread_spawn_edges (status = "open" — note: even completed edges show status "open", suggesting the edge status itself may not be updated)
  4. The spawned npm exec @playwright/mcp@latest and its node playwright-mcp child remain alive indefinitely

Immediate workaround

pkill -f "playwright-mcp"
pkill -f "npm exec @playwright/mcp"

This instantly freed ~13.6 GB. Playwright MCP respawns correctly for the next thread that needs it.

Expected behavior

  • MCP child processes should be terminated when their owning thread/session closes
  • Subagent sessions should either share the parent's MCP connections or reliably clean up their own
  • The codex app-server should not accumulate unbounded child processes over the course of normal use

Related issues

  • #16895 — closed as fixed April 9, but the bug persists (this report)
  • #17574 — same leak pattern with xcodebuildmcp and chrome-devtools-mcp (open)
  • #12491 — original report: 1300+ zombies, 37 GB leak (open)
  • #12333 — duplicate Serena MCP instances from multi-agent spawns (closed)

extent analysis

TL;DR

The most likely fix for the leaked Playwright MCP stdio processes is to properly terminate the MCP child processes when their owning thread/session closes, which can be temporarily worked around by manually killing the processes using pkill.

Guidance

  • Investigate the codex_core::spawn and codex_mcp::mcp_connection_manager modules to ensure that MCP connections are properly cleaned up when subagent sessions close.
  • Review the thread_spawn_edges table in state_5.sqlite to understand why the edge status is not updated correctly, which may be related to the leak.
  • Consider implementing a mechanism to share MCP connections between subagent sessions or to reliably clean up connections when sessions close.
  • Use the provided pkill commands as a temporary workaround to free up memory consumed by leaked processes.

Example

No code snippet is provided as the issue is more related to process management and cleanup rather than a specific code fix.

Notes

The issue seems to be related to the lifecycle management of MCP child processes and their connection to subagent sessions. The fact that the pkill workaround frees up memory suggests that the issue is with the process cleanup mechanism. Further investigation is needed to identify the root cause and implement a proper fix.

Recommendation

Apply the workaround using pkill to temporarily mitigate the issue, as the root cause is still under investigation and a proper fix is not yet available. This will help prevent the accumulation of leaked processes and reduce memory consumption.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

  • MCP child processes should be terminated when their owning thread/session closes
  • Subagent sessions should either share the parent's MCP connections or reliably clean up their own
  • The codex app-server should not accumulate unbounded child processes over the course of normal use

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Regression: Playwright MCP stdio processes still leak after #16895 fix — 213 orphaned pairs, 13.6 GB RSS [3 comments, 2 participants]