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_

贡献指南

打开贡献指南

调研方向

Start with the `copilot` shell executable and `copilotCLIShim.js`, then reproduce the `copilot --yolo --prompt "say hello" --model claude-sonnet-4.6 --silent --disable-builtin-mcps` command while monitoring `copilotCli` processes. Trace how the shim and native execution invoke each other. Done means a single command no longer creates unbounded child processes or reaches an OOM/system hang.

由索引模型根据 Issue 内容生成。

评估

技术栈
javascript, shell
领域
cli
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。