Skip to content

Session service: node-pty resize on a closed PTY throws ioctl(2) EBADF #199

Description

@raiseCatError

Observed

The #127 service test handshake, version mismatch, framing, containment, registry, and disconnect policy (tests/sessionService.test.ts) fails intermittently under full-suite load with:

Error: ioctl(2) failed, EBADF

Seen repeatedly in local full-suite runs while working on #131 and #197 (roughly 1 in 3 to 5 runs on a heavily loaded machine). Not yet seen in CI. The test passes when run alone.

Likely context (not yet confirmed)

node-pty throws synchronously from pty.resize() when the PTY file descriptor is already closed, for example when a resize reaches a session whose shell has just exited or is being torn down. ShellSession.resize calls this.pty.resize(...) without a guard. The session service handles client resize messages (and its own redraw-nudge resizes on attach) for sessions that can exit concurrently.

Why it matters

If the throw happens inside the long-lived session service rather than a test process, an uncaught exception could take nmshd down along with every live session it owns.

Reproduction

  • Run npm test repeatedly on a loaded machine and watch the handshake test above.
  • Or run node --import=tsx --test tests/sessionService.test.ts in a loop under CPU load.

Next step

Confirm the exact throwing call site, then decide the handling. Not started; deliberately deferred from the #197 work.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions