Skip to content

[Bug]: Closing a terminal just before owner shutdown can leave its root running #37112

Closed

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Open a terminal through TerminalManager using the real NodePtyAdapter on Linux. Start Bash and exec a Node TCP server as the session root. Have it acknowledge SIGTERM and answer PING with PONG over an established socket.
  2. Explicitly close the terminal and await the root's SIGTERM acknowledgement.
  3. Close the manager's owning Effect scope while its configured kill grace is pending.
  4. Send PING on the established socket after scope closure.

Expected behavior

The explicitly closed root completes the existing SIGTERM-to-SIGKILL escalation during teardown. Pending termination remains owned even after the session leaves the manager's session map.

Actual behavior

The root responds PONG after teardown. Closing the worker scope interrupts its pending escalation, and the shutdown finalizer only visits sessions still in the map. Close-only and scope-only controls terminate the same producer.

Impact

Minor bug or occasional failure. The tested ordering reproduces deterministically; population incidence is unknown.

Version or commit

Reproduced on upstream main 2cb2fa1 and independently confirmed earlier on 2dc5ebd. Rechecked on subsequent upstream main using the same native probe.

Environment

Linux native backend, NodePtyAdapter, Bash exec of Node as session root. No full desktop quit, WebSocket, Windows, mobile or systemd reproduction; no detached-descendant claim.

Logs or stack traces

base, explicit close -> TERM acknowledgement -> owner scope close -> PING: pong
base, focused Manager test: expected ['SIGTERM'] to equal ['SIGTERM', 'SIGKILL']

Screenshots, recordings, or supporting files

Found by the terminal lifecycle bughunt and independently confirmed by Claude Opus 5.5. Finding: https://zws2e1uvwoad.postplan.dev

Workaround

Let an explicit close finish termination before shutting down the owner, or stop the process cooperatively.

Activity

  1. added
    vouch:trusted
    on Nov 15, 2026
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

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions