github / github/copilot-cli

nfinite recursion (Shim <-> Native ping-pong) when executing copilotCLI via copilotCLIShim.js

未關閉
#2,274 0 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
area:installation
主要語言
Shell
星號
11.2k
分支
1.9k
平均合併
14 小時 16 分鐘
30 天內合併 PR
6

描述

### Describe the bug

## GitHub Issue Draft

**Title:** Infinite recursion (Shim <-> Native ping-pong) when executing `copilotCLI` via `copilotCLIShim.js`

### Description
While developing tools utilizing `copilotCli`, I discovered a critical bug where the process spawns child processes indefinitely, leading to an Out of Memory (OOM) state or system hang.

Based on the analysis of the agent conversation history and process monitoring, the issue is not within the VS Code extension itself, but rather a **recursive execution loop** within the `copilot` CLI binary/shim layer.

### Analysis & Evidence
The `copilot` executable is a shell script that calls `copilotCLIShim.js` using Electron as Node:

```sh
#!/bin/sh
unset NODE_OPTIONS
ELECTRON_RUN_AS_NODE=1 "/usr/share/code/code" "/home/dhyang/.config/Code/User/globalStorage/github.copilot-chat/copilotCli/copilotCLIShim.js" "$@"
```

When a single `copilot` command is executed, the process count explodes exponentially. In a controlled test, a single call resulted in over **2,100 processes** within 60 seconds (approximately 37 forks per second).

### Investigation Log
Below is the terminal output capturing the abnormal process growth during a single execution:

```bash
# Monitoring process count in background
while true; do n=$(pgrep -c -f "copilotCli" 2>/dev/null || echo 0); echo "$(date +%H:%M:%S) procs=$n"; sleep 1; done

# Executing a single command
START: 14:30:01
timeout 60 copilot --yolo --prompt "say hello" --model claude-sonnet-4.6 --silent --disable-builtin-mcps
...
END: 14:31:01 exit:124 (Timeout)
```

**Key Findings:**
* **Process Explosion:** 0 → 2,198 processes in 60 seconds.
* **Symptom:** The `copilot` CLI binary continuously forks child processes without termination.
* **Root Cause Hypothesis:** A "ping-pong" recursion between the `copilot` shim script and the native execution logic, where each process attempts to invoke another instance of itself.

### Environment
* OS: Linux (Ubuntu/Debian based on `/usr/share/code` path)
* Extension: github.copilot-chat
* Component: copilotCli / copilotCLIShim.js

### Affected version

GitHub Copilot CLI 1.0.11.

### Steps to reproduce the behavior

_No response_

### Expected behavior

_No response_

### Additional context

_No response_

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。