CopilotClient.stop() leaks the CLI server's child process tree on Windows (orphaned node/copilot.exe per session)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- python
調査の方向性
client.py、特に CopilotClient.stop() と StdioRuntimeConnection のプロセス作成を調査し、子プロセスを追跡しながら issue に記載された Windows の create_session()/stop() ループを再現します。Windows と POSIX でライフサイクルの動作を比較し、記載されている Job Object または process-group のアプローチを検討します。起動したクライアントを停止したときに、node.exe または copilot.exe の孤児となった子孫プロセスが残らなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Summary
On Windows, CopilotClient.stop() does not terminate the CLI server's child process tree — only the top-level launcher process. Every create_session() / stop() cycle therefore orphans a full copilot process tree (node.exe + the copilot.exe broker/worker/webview helpers) that survives until its own idle timeout. In a long-running app that creates one client/session per unit of work (e.g. a batch/eval harness), this is a deterministic ~1 leaked process tree per session, which accumulates and eventually OOMs the host.
Environment
github-copilot-sdk(Python)1.0.0b7(also visible by inspection in currentclient.py)- Copilot CLI runtime
1.0.66-0 - Windows 11, Python 3.11 (miniconda)
- Transport:
StdioRuntimeConnection,use_logged_in_user=True
Root cause
CopilotClient.stop() only calls terminate() / kill() on its own launcher Popen (self._process):
# client.py (stop)
if self._process and not self._is_external_server:
self._process.terminate()
try:
self._process.wait(timeout=5)
except subprocess.TimeoutExpired:
self._process.kill()
self._process = None
On Windows, terminating the launcher does not cascade to its descendants. The launcher (copilot.cmd → cmd.exe) spawns node.exe, which spawns the real copilot.exe server + helper processes; these are left orphaned and alive after stop().
Reproduction
import asyncio, psutil
from copilot import CopilotClient, StdioRuntimeConnection
CLI = r"C:\Users\<you>\AppData\Roaming\npm\copilot.cmd"
def n_copilot():
return sum(p.info["name"] == "copilot.exe"
for p in psutil.process_iter(["name"]))
async def main():
for i in range(5):
client = CopilotClient(
connection=StdioRuntimeConnection(CLI, []),
use_logged_in_user=True,
)
session = await client.create_session()
await session.send("hello")
# ...consume events until SessionIdle...
await session.disconnect()
await client.stop()
print(f"iter {i}: copilot.exe alive = {n_copilot()}")
asyncio.run(main())
Observed (Windows): copilot.exe alive grows 1, 2, 3, 4, 5 — one orphaned tree per iteration, none reaped by stop().
Expected
After await client.stop() (for a client that spawned the server), the entire CLI server process tree should be terminated, leaving no orphaned node.exe / copilot.exe processes.
Workaround
Capture the launcher PID after create_session() and kill the whole tree explicitly on teardown — e.g. psutil.Process(pid).children(recursive=True) + kill all (enumerate before killing the parent), or taskkill /F /T /PID on Windows / os.killpg on POSIX.
Suggested fix
Have the SDK own the process-tree lifecycle so stop() reaps descendants:
- Windows: assign the launcher to a Job Object with
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE, so the OS atomically kills the tree when the job/handle closes. - POSIX: spawn with
start_new_session=Trueandos.killpg(os.getpgid(pid), SIGKILL)on stop. - Or a
psutil-based recursive child kill insidestop().
This is likely related to the CLI-side reports of orphaned processes (e.g. github/copilot-cli#1368, #2279) but is reproducible purely through the SDK's own create_session()/stop() lifecycle.
- 主要言語
- TypeScript
- スター
- 10.5k
- フォーク
- 1.5k
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 98
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/copilot-sdk のほかの issue
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
github/copilot-sdk#2804 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
github/copilot-sdk#2798 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
github/copilot-sdk#2793 ·
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
github/copilot-sdk#2782 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
github/copilot-sdk#2781 ·
メンテナーはふだん 1 日以内に返信
github/copilot-sdk の issue をすべて見る
似ている issue
-
check:failed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
iptv-org/iptv#53974 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
interledger/rafiki#3986 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Doist/todoist-cli#576 ·
メンテナーはふだん 1 日以内に返信
-
feature
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
vercel-labs/skills#2370 ·
メンテナーはふだん 1 日以内に返信
-
🐛 Bug supabase/cli
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信