Skip to content

P2: Pre-v31 attach-only accidental spawn leave orphan if kill fails #12662

Open

Description

@AmethystLiang

Priority

P2 — nice-to-have / narrow impact (from prod-release scan of subscriber-driven daemon attach).

Summary

Subscriber-driven attach for never-activated local daemon sessions uses attachOnly: true. On pre-v31 daemons that ignore attachOnly, createOrAttach can return isNew: true (accidental spawn). The adapter retires that spawn with an immediate kill and throws SessionNotFoundError so the accidental shell is not published as a successful attach.

If that kill fails, the failure is only console.warn’d. The accidental shell can remain as an untracked orphan on the daemon host.

Evidence

Impact

  • Rare: only pre-v31 / legacy daemon protocol paths
  • Correctly does not pin a sticky “attach succeeded” for a blank stream (degraded-provider refusal is separate)
  • Worst case: one orphan shell per failed retire, diagnosable only via logs unless operator inspects daemon sessions

Suggested fix

  • Surface a structured runtime/telemetry event (not only warn) so support can find orphans
  • Retry kill once with backoff, or schedule a best-effort reaper for known accidental session ids
  • Optional: expose orphan session ids in daemon diagnostics / listProcesses audit

Acceptance

  • Failed attach-only retire is observable beyond a single console line
  • Still never publishes an isNew legacy spawn as a successful subscriber attach
  • Tests keep covering kill-failure surfacing (adapter test already pins warn path)

Source

Prod-release scan of curated PRs including #12589 (2026-08-05).

Activity

  1. added
    bugSomething isn't working
    and removed on Aug 5, 2026
  2. added a commit that references this issue on Sep 20, 2026
    557663e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingterminal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions