byterover-cli icon indicating copy to clipboard operation
byterover-cli copied to clipboard

`brv mcp` client stuck in infinite exception loop consuming 75–90% CPU for hours

Open txomin-jimenez opened this issue 6 months ago • 2 comments

Pre-flight checklist

  • [x] I have searched existing issues and this bug has not been reported yet

Bug description

When the brv mcp MCP client process encounters an unhandled exception, it enters an infinite CPU-bound loop instead of exiting. The process silently pegs CPU at 75–90% and can run for several hours undetected. It is not visible in any brv tooling, produces no log output, and ignores SIGTERM — requiring kill -9 to terminate.

This has been reproduced across multiple Claude Code sessions on macOS.

Steps to reproduce

  1. Use brv as an MCP server in Claude Code
  2. Trigger a condition that causes an unhandled exception in the brv mcp client process (exact trigger unknown — occurs intermittently across sessions)
  3. Keep Claude Code session opened for a while.
  4. Run ps aux | grep "brv mcp" — a zombie node /usr/local/bin/brv mcp process remains

Expected behavior

The brv mcp process should exit cleanly (or restart) when an unhandled exception occurs. At minimum it should log the error and call process.exit(1).

Actual behavior

The process enters an infinite loop inside the V8 engine: an unhandled exception triggers the uncaughtException handler, which constructs a new Error object, which triggers another uncaught exception — and so on indefinitely. The process:

  • consumes 75–90% CPU for hours
  • ignores SIGTERM (requires kill -9)
  • writes nothing to any log
  • is not detectable via brv tooling — only via ps aux

CLI version

byterover-cli/3.12.0 darwin-x64 node-v22.22.2

Installation method

npm

Node.js version

v22.22.2

Operating system

macOS (ARM64 / Apple Silicon)

LLM provider and model

No response

Relevant logs

No log output is produced by the process. The following was captured via the macOS sample profiler (5 seconds, 1ms interval) on PID 87488:

  Process:  node [87488]  —  node /usr/local/bin/brv mcp
  Platform: macOS 15.7.3 (24G419) / Node.js 22.22.2 x86-64

  Call graph:
      3831 Thread_10881513   DispatchQueue_1: com.apple.main-thread  (serial)
      + 3831 start  (in dyld)
      +   3831 node::Start(int, char**)
      +     3831 node::NodeMainInstance::Run()
      +       3831 node::SpinEventLoopInternal(node::Environment*)
      +         3829 uv_run
      +         ! 3829 uv__run_check
      +         !   3828 node::Environment::CheckImmediate(uv_check_s*)
      +         !   : 3826 node::InternalMakeCallback(...)
      +         !   : | 3704 node::InternalMakeCallback(node::Environment*, ...)
      +         !   : | + 3702 v8::Function::Call(...)
      +         !   : | + !   2663 v8::internal::Invoke(...)
      +         !   : | + !   : 2662 v8::internal::Isolate::ReportPendingMessages(...)
      +         !   : | + !   : | 2621 v8::internal::MessageHandler::ReportMessage(...)
      +         !   : | + !   : | + 2590 ReportMessageNoExceptions(...)
      +         !   : | + !   : | + ! 2555 node::errors::TriggerUncaughtException(...)
      +         !   : | + !   : | + ! : 2553 v8::Function::Call(...)   <- calls error handler
      +         !   : | + !   : | + ! : | + 2523 v8::internal::Invoke(...)
      +         !   : | + !   : | + ! : | + !   2522 ???  (JS error handler in brv)
      +         !   : | + !   : | + ! : | + ! :   2491 ???  (constructs new Error)
      +         !   : | + !   : | + ! : | + ! :   | 1276 v8::internal::Builtin_ErrorConstructor(...)
      +         !   : | + !   : | + ! : | + ! :   |   1269 v8::internal::ErrorUtils::Construct(...)
      +         !   : | + !   : | + ! : | + ! :   |   + 1263 Isolate::CaptureAndSetErrorStack(...)
      +         !   : | + !   : | + ! : | + ! :   |   + ! 1166 CaptureSimpleStackTrace(...)  <- ~1200 frames/ms
      +         !   : | + !   : | + ! : | + ! :   |   + ! : 734 OptimizedFrame::Summarize(...)

Daemon log (server-2026-05-14T09-41-33.log) shows no errors — the daemon (PID 76386) was fully healthy throughout. The stuck process is a separate client-side brv mcp instance.

txomin-jimenez avatar May 14 '26 13:05 txomin-jimenez

Hey @txomin-jimenez, this should be fixed in v3.14.0 (just shipped) - see #664 for the gory details. The MCP client now bails out cleanly on uncaught exceptions and shuts down within 2s instead of spinning forever.

Reinstall, run brv restart, then restart your MCP host so it picks up a fresh brv mcp. Reopen if it still pegs CPU - and thanks for the sample profiler dump, that made this a 10-minute fix instead of a week-long ghost hunt.

bao-byterover avatar May 18 '26 09:05 bao-byterover

Amazing, thanks! Just updated and restarted. fingers crossed it doesn't zombie on me again 😄

Really glad the sample dump helped. Wasn't sure if it would be useful or just noise, so good to know it saved some digging.

txomin-jimenez avatar May 18 '26 18:05 txomin-jimenez