Skip to content

Bug Report: Windows Terminal Tabs Accumulate Due to MCP Connection Failures #625

Description

@s1495k043

Bug Description

When using claude-mem's PostToolUse hook on Windows, failed MCP server connections cause Windows Terminal to open new tabs that don't automatically close. Over time, this results in dozens or hundreds of accumulated terminal tabs, each showing error messages from failed uvx process executions.

The root cause is a combination of:

  1. uvx spawning new terminal windows/tabs on Windows
  2. Processes exiting with non-zero exit codes due to connection failures
  3. Windows Terminal's default closeOnExit: "graceful" behavior keeping failed tabs open

Steps to Reproduce

  1. Install claude-mem on Windows with Windows Terminal as the default terminal
  2. Configure claude-mem with MCP server settings (or have misconfigured/unreachable MCP server)
  3. Use Claude Code and execute any tool that triggers PostToolUse hook
  4. Observe that each tool execution opens a new Windows Terminal tab
  5. Notice that tabs showing errors remain open and accumulate over time

Error Messages Observed

  1. Hook Execution Failure:
    Plugin hook bun worker-service.cjs start failed to start: The operation was aborted

  2. Health Check Failures:
    Worker failed to start (health check timeout)
    Failed to start server. Is port 37777 in use?

  3. Windows Compatibility Issue:
    'wmic' is not recognized as an internal or external command

  • Root cause: WMIC deprecated/removed in Windows 11
  • Affects: ProcessManager.ts lines 91-92, 174
  1. Consequential Errors:
    Database not initialized

Process Leak Evidence

  • 121 orphaned claude CLI processes accumulated over 6 hours
  • Total memory consumption: ~44GB RSS
  • Each process: ~372MB average
  • All child processes remain running after task completion

Expected Behavior

  • PostToolUse hook executions should not open visible terminal windows/tabs
  • OR failed processes should clean up and close terminals automatically
  • Users should not experience terminal tab proliferation during normal Claude Code usage

Actual Behavior

  • Each PostToolUse hook execution spawns a new Windows Terminal tab via uvx
  • When MCP server connection fails or errors occur, tabs remain open with error messages
  • Tabs accumulate continuously, requiring manual cleanup

Environment

  • Claude-mem version: Latest (from marketplace)
  • Claude Code version: Latest
  • OS: Windows 11 (or Windows 10)
  • Terminal: Windows Terminal (powershell 7)
  • Runtime: uvx (0.7.19 (38ee6ec80 2025-07-02))

Related Issues

This appears related to #213, which discusses Windows process management issues and the migration from uvx to Bun runtime.

Suggested Solutions

Short-term workarounds:

  1. Change Windows Terminal's closeOnExit setting to "always" in settings.json
  2. Ensure MCP server connection is properly configured to minimize failures
  3. Switch to Bun runtime if available (as mentioned in Worker service / MCP spawns endless node → uvx → chrome_mcp → python processes on Windows 11  #213)

Long-term fixes:

  1. Complete the migration to Bun runtime for better Windows process management
  2. Implement silent/headless execution for hook processes
  3. Add proper error handling so failed processes exit gracefully (exit code 0)
  4. Consider using Windows-specific process spawning methods that don't create visible windows

Additional Context

The Windows Terminal behavior is technically correct - it keeps tabs open on error to allow users to see error messages. However, this conflicts with claude-mem's hook pattern of frequent background executions, leading to UX degradation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions