Skip to content

bug(pty): MSVC assertion crash on close — remove_pty_baton(baton->id) #50

@schroldgames

Description

@schroldgames

Environment

  • wmux: v0.8.7
  • Windows (any)

Behavior

When closing wmux, a Microsoft Visual C++ Runtime Library dialog appears:

Assertion failed!
Program: ...wmux.exe
File: ...
Expression: remove_pty_baton(baton->id)

The crash is intermittent — more likely when multiple terminal panes are open.

Root cause

The will-quit handler stops ancillary services (pipe server, CDP proxy, port scanner, pollers) but never explicitly kills the PTY processes:

app.on('will-quit', () => {
  pipeServer.stop();
  cdpProxy.stop();
  portScanner.stop();
  gitPoller.unwatchAll();
  prPoller.stopAll();
  // ← ptyManager.killAll() missing
});

When Electron exits without calling ptyManager.killAll(), node-pty's libuv async handles (called "batons") are still pending as the Node.js runtime tears down. The remove_pty_baton assertion fires because node-pty attempts to clean up those handles in a partially-destroyed state.

Fix

Call ptyManager.killAll() as the first step in the will-quit handler, before any other teardown runs. This gives node-pty time to complete its cleanup before the process exits.

app.on('will-quit', () => {
  ptyManager.killAll(); // ← add this
  pipeServer.stop();
  // ...
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions