[Bug] Session server freezes due to excessive 'Peer not connected' logging

Resolved 💬 3 comments Opened Dec 26, 2025 by nontangent Closed Feb 14, 2026

Summary

machina session server start --name <server-name> freezes after running for extended periods due to excessive warning log output, causing the Node.js process to enter Uninterruptible Sleep (UE) state.

Environment

  • machina version: 0.0.0-pr870.20251226001435
  • OS: macOS Darwin 23.5.0 (Apple Silicon M2)
  • Node.js: 22.12.0

Symptoms

  1. Session server process becomes unresponsive (process state: UE - Uninterruptible Sleep)
  2. machina session server start --name macbook-air-m2 command hangs indefinitely
  3. Daemon restart commands also become stuck
  4. MCP operations timeout

Root Cause Analysis

Log File Analysis

The server log (~/.machina/macbook-air-m2/server.log) shows:

[2025-12-26T04:43:27.839Z] [LOG] [WARN] [PeerService] [send] Peer not connected: MFkw... connected: false Available connected peers: [...]
[2025-12-26T04:43:27.839Z] [LOG] [WARN] [PeerService] [send] Peer not connected: MFkw... connected: false Available connected peers: [...]
[2025-12-26T04:43:27.854Z] [LOG] [WARN] [PeerService] [send] Peer not connected: MFkw... connected: false Available connected peers: [...]
... (dozens more per second)
[2025-12-26T04:43:28.xxx] (logs stop here - process frozen)

Issues Identified

  1. Log Spam: "Peer not connected" warnings are logged dozens of times per second when a peer is disconnected
  2. No Rate Limiting: No throttling on log output for repeated warnings
  3. I/O Blocking: High-frequency file writes to server.log (6.6MB) causes I/O blocking
  4. Infinite Send Loop: The system continuously attempts to send to disconnected peers

Process State

$ ps aux | grep session
nozomu.miyamoto  18558   0.0  0.2 426575088  42176   ??  UE   11:22AM  44:43.07 node /Users/nozomu.miyamoto/.bun/bin/machina session server start --name macbook-air-m2
  • State: UE (Uninterruptible sleep + Extensions active)
  • CPU time: 44 minutes of actual CPU usage
  • Started: 11:22AM, frozen around 13:43

Suggested Fixes

  1. Add rate limiting to PeerService logs:
  • Implement exponential backoff or cooldown for repeated "Peer not connected" warnings
  • Log at most once per peer per N seconds
  1. Stop sending to known-disconnected peers:
  • Mark peers as disconnected and skip send attempts
  • Only attempt reconnection via the reconnect mechanism
  1. Async logging or buffered writes:
  • Use async file writes for logging to prevent I/O blocking

Steps to Reproduce

  1. Start a session server: machina session server start --name test-server
  2. Connect multiple clients/peers
  3. Disconnect one or more peers
  4. Wait several hours
  5. Observe server becomes unresponsive

Workaround

Currently, the only workaround is to kill the frozen process and restart:

kill -9 <PID>
rm -f /tmp/machina-session-daemon.sock
machina session daemon restart

Additional Context

  • Log file at the time of freeze: 6,661,314 bytes
  • The daemon log shows repeated Connection timeout errors attempting to connect to this server
  • Multiple servers affected (same pattern observed across different server names)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗