Skip to content

hzdb mcp server: Connection leak causes 99% CPU usage (CLOSE_WAIT) #2

@gagarinyury

Description

@gagarinyury

Bug Report

Version: hzdb 1.0.1 (darwin-arm64)
OS: macOS 26.3.1 (arm64)
Command: hzdb mcp server

Description

When running hzdb mcp server, the process creates a telemetry connection to edge-oculus-shv-01-cdg4.fbcdn.net:https that gets stuck in CLOSE_WAIT state. This causes the process to enter an infinite loop, consuming ~99% CPU continuously.

Symptoms

  • Process state: R+ (Running)
  • CPU usage: ~99% continuously
  • Network connection: CLOSE_WAIT to edge-oculus-shv-01-cdg4.fbcdn.net:https
  • Accumulated CPU time: 63+ minutes in ~1 hour of runtime

Logs

2026-04-12T09:37:13.303370Z  INFO hzdb_lib::commands::mcp::server: Starting HzOS MCP server v1.0.0 (via hzdb)
2026-04-12T09:37:13.303921Z  INFO hzdb_lib::telemetry::telemetry_impl: Telemetry session started (DeveloperTelemetry) server_name="hzdb" server_type="production" server_version=hzdb/1.0.0 telemetry_app_name="hzso_dev_mcp_server" falco_event="hzos_dev_mcp_server_events"

Network Connection (lsof output)

hzdb    93547 yurygagarin   12u  IPv4 0x88e6fcc3b843b3e3      0t0  TCP 192.168.1.15:52583->edge-oculus-shv-01-cdg4.fbcdn.net:https (CLOSE_WAIT)

Process Info (ps output)

PID    %CPU  TIME     COMMAND
93547  99.2  63:58.01 /Users/yurygagarin/code/Iwsdk/node_modules/@meta-quest/hzdb-darwin-arm64/bin/hzdb mcp server

Steps to Reproduce

  1. Start hzdb mcp server through an MCP client (e.g., via Claude/MCP configuration)
  2. Wait 2-3 seconds
  3. Check lsof -p <pid> - connection to edge-oculus-shv-01-cdg4.fbcdn.net:https is in CLOSE_WAIT
  4. Process CPU usage climbs to ~99%

Root Cause

The CLOSE_WAIT state indicates:

  1. Remote server (Meta) sent FIN packet to close connection
  2. hzdb sent ACK to acknowledge
  3. hzdb never sends FIN to complete the close sequence
  4. Process continues trying to read/write to the dead connection → infinite loop

Expected Behavior

  • Telemetry connection should either stay ESTABLISHED or properly close
  • Process should not consume 99% CPU when idle
  • Proper timeout handling for network errors

Actual Behavior

  • Telemetry connection stuck in CLOSE_WAIT
  • Process consumes ~99% CPU continuously
  • Multiple zombie processes accumulate over time

Environment

  • macOS: 26.3.1 (arm64)
  • Node: v25.2.1
  • hzdb: 1.0.1 (darwin-arm64 binary)
  • Started via: .mcp.json configuration with npx @meta-quest/hzdb mcp server

Workaround

Kill the affected process:

kill <pid>

Or disable the MCP server in .mcp.json:

{
  "mcpServers": {
    "hzdb": {
      "command": "npx",
      "args": ["@meta-quest/hzdb", "mcp", "server"]
    }
  }
}

Additional Notes

  • Issue is reproducible consistently
  • Occurs regardless of whether Meta Quest device is connected
  • Multiple hzdb processes can accumulate, each consuming high CPU
  • Telemetry session starts immediately on server startup

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions