Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Client stop paths treat EPERM as a confirmed exit and drop state for a live companion

クローズ
#3,540 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

関連するプルリクエストがすでにマージされています。

  • #3551 @thymikee による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
cli

調査の方向性

Read the two stop paths in src/client/client-companion-tunnel.ts and src/metro/client-metro.ts, then compare their behavior with the daemon stopper in packages/daemon-contracts/src/daemon-process.ts. Trace the callers that delete companion state or swallow errors, and check the close-code path in src/client/client-companion-tunnel-worker.ts. Done means live processes keep tracked state and report a typed failure, confirmed exits report stopped, and close-code behavior stays unchanged.

索引モデルが issue の本文から書いたものです。

説明

What happens

A companion (or a dev server we spawned) that refuses our signal because it belongs to another user
is recorded as stopped, and its tracked state is deleted while the process keeps running.

Reproduce the companion case with a companion started under another owner (for example via sudo),
then run any command that ends the Metro/DevTools companion tunnel:

agent-device connect --remote-config /tmp/remote.json --proxy-base-url https://bridge.example.test
sudo <start a companion for the same profile>   # owns the recorded pid
agent-device disconnect --remote-config /tmp/remote.json
agent-device connect --remote-config /tmp/remote.json   # starts a *second* companion

disconnect reports success, ~/.agent-device/.agent-device companion state is gone, and the next
connect spawns a second companion while the first is still registered for the same bridge scope.

Why

Both client stop paths read EPERM from process.kill as "already exited" and return early:

  • stopCompanionProcess in src/client/client-companion-tunnel.ts (~283-305) returns, and both
    callers then delete the state file, so stopCompanionTunnel reports stopped: true and the next
    ensureCompanionTunnel starts a companion beside the surviving one.
  • stopSpawnedMetroProcess in src/metro/client-metro.ts (~412-429) does the same, and its only
    caller (~851) ends in .catch(() => {}), so even its throw branches are unobservable.

EPERM means the opposite of absence: the process exists and is not ours to signal. Only ESRCH, or
a liveness probe that stops answering, proves an exit. The daemon's own stopper already gets this
right — packages/daemon-contracts/src/daemon-process.ts (~145-175) reports retained /
signal-failed instead of dropping its registration.

Expected

Signal, then confirm. A stop reports stopped only for a process whose exit was confirmed; a
process that survived every signal keeps its tracked state and fails with a typed reason, so a retry
stops the same process instead of starting a second one.

Also in this area

normalizeCloseCode's keep-list in src/client/client-companion-tunnel-worker.ts (~209-223) is dead
for codes 1001-1015 and the 1011 fallback, because the only path through it
(~401 → ~277) runs normalizeOutgoingCloseCode afterwards. The two should be one function with no
wire-behavior change.

主要言語
TypeScript
スター
5k
フォーク
334
平均マージ
13時間 19分
マージ済み PR(30日)
630

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

callstack/agent-device のほかの issue

callstack/agent-device の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。