Skip to content

Bug: Multi-Session Hang - Only Latest CLI Session Works (WSL2 + OAuth) #13448

Closed as not planned

Description

@saadfaruque99

Bug Report: Multi-Session Hang - Only Latest Session Works

Summary

When running multiple concurrent Claude Code CLI sessions, only the most recently active session maintains API connections. Other sessions become unresponsive ("hung") with zero API connections.

Environment

Property Value
Claude Code Version 2.0.62
OS Ubuntu 24.04 LTS (WSL2)
Kernel 5.15.x-microsoft-standard-WSL2
Platform x86_64 (Windows 11 + WSL2)
Authentication Claude Max subscription (OAuth)

Steps to Reproduce

  1. Open 3 separate terminal windows in WSL2
  2. Start claude in each terminal
  3. Give each session a task (e.g., "what is 2+2")
  4. Observe: Only the LAST session given a task responds
  5. The other 2 sessions become completely unresponsive

Expected Behavior

All 3 sessions should work independently and respond to commands.

Actual Behavior

  • Only the most recently active session works
  • Other sessions hang indefinitely
  • Pressing Escape in hung sessions shows "process has stopped"
  • claude -c (resume) also fails for hung sessions
  • Only starting a completely new session works

Diagnostic Evidence

Connection Analysis

When examining socket connections during the hang:

Session 1 (started first):  0 API connections  → HUNG
Session 2 (started second): 0 API connections  → HUNG
Session 3 (started last):   1+ API connections → WORKING

The hung sessions have zero connections to Anthropic's API servers.

Process State

All processes show identical states:

  • State: S (sleeping)
  • Syscall: 281 (epoll_pwait) - waiting for I/O events
  • But hung sessions have no connections, so no events will ever arrive

Debug Log Errors

Frequent AggregateError from TLS socket layer:

[ERROR] AggregateError: AggregateError
    at emitErrorEvent (node:_http_client:104:11)
    at TLSSocket.socketErrorListener (node:_http_client:518:5)

Also observed:

[ERROR] Error streaming, falling back to non-streaming mode: Connection error.

What We Ruled Out

Hypothesis Test Result
Idle connection timeout Applied TCP keepalive (60s) Did not fix
Session file accumulation Cleaned old session files Did not fix
OAuth token issue Full logout/login cycle Did not fix
Network connectivity curl to API works fine Not the issue
Rate limiting No 429 errors in logs Not the issue

Root Cause Hypothesis

The bug appears to be in Claude Code's connection management when multiple instances share the same OAuth credentials. When a new session makes an API request:

  1. Something causes existing sessions' connections to be invalidated/closed
  2. The existing sessions do not recover or attempt to reconnect
  3. They remain in epoll_pwait forever, waiting for events on dead/non-existent connections

System Resources During Hang

  • CPU: ~99% idle (not resource exhaustion)
  • Memory: No pressure
  • Swap: Unused
  • File descriptors: Normal counts

Workarounds

  • Use only 1 CLI session at a time
  • VSCode extension appears more stable for multi-session scenarios

Impact

  • Severely limits productivity for users who work with multiple terminal sessions
  • Forces single-session workflow
  • Requires manual process termination to recover

Additional Information

Detailed diagnostic data (process states, socket dumps, debug logs) available upon request.

Activity

  1. github-actions commented on Dec 9, 2025

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] Only one Claude Code session possible #7517
    2. [Bug] Previous session becomes unresponsive when opening new session in same project #13268
    3. [Bug] Multiple Claude Code instances freeze on macOS due to file locking conflict #13287

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. saadfaruque99 commented on Dec 9, 2025

    @saadfaruque99
    Author

    Possibly Related: #13287 reports similar multi-session blocking behavior on macOS.

    Key Differences:

    The symptom is the same (only one session works at a time), but the underlying errors differ. These may be separate bugs with similar manifestation, or different symptoms of the same concurrency issue. Linking for visibility.

  3. KCW89 commented on Dec 14, 2025

    @KCW89

    Confirming this issue on macOS (not just WSL2)

    Environment

    Property Value
    Claude Code Version 2.0.69
    OS macOS 15.5 (Sequoia)
    Platform arm64 (Apple Silicon)
    Authentication Claude Max (OAuth)

    Reproduction

    Running 2-3 concurrent terminal sessions in different project directories. When switching between terminals, the inactive session(s) hang completely. Only the most recently active terminal responds.

    Additional Observations

    Initially, suspected custom hooks were causing the issue. After extensive debugging:

    1. Removed all UserPromptSubmit hooks (ran on every prompt)
    2. Reduced global hooks from 13 Python processes to 3 echo commands
    3. Simplified project hooks toa minimal set

    Result: Hooks weren't the root cause. The multi-session connection issue persists even with minimal hook configuration.

    Symptoms Match Exactly

    • Active terminal: responds normally
    • Inactive terminal(s): completely frozen, no response to input
    • Switching terminals: newly active one works, previous one freezes

    This confirms the issue affects macOS + Apple Silicon, not just WSL2/Linux.

  4. github-actions commented on Jan 15, 2026

    @github-actions

    This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

  5. github-actions commented on Feb 14, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  6. github-actions commented on Feb 21, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  7. locked as resolved and limited conversation to collaborators on Feb 21, 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

    area:autharea:coreautocloseIssue will be closed automaticallybugSomething isn't workinghas reproHas detailed reproduction stepsplatform:linuxIssue specifically occurs on Linux

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions