github / github/copilot-cli

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

Open
#2,274 0 comments 2 reactions 0 assignees View on GitHub
area:installation
Dominant language
Shell
Stars
11.2k
Forks
1.9k
Avg merge
14h 16m
Merged PRs (30d)
6

Description

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.