Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Fermée
#3,540 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Une pull request liée a déjà été fusionnée.

  • #3551 par @thymikee — fusionnée

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
52/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
node.js, typescript
Domaine
cli

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
TypeScript
Étoiles
5k
Forks
334
Merge moyen
11 h 48 min
PR mergées (30 j)
605

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de callstack/agent-device

Toutes les issues de callstack/agent-device

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.