Skip to content

v1.0.121: nested pi --help spawns orphaned MCP servers spinning at 100% CPU #534

@gebeer

Description

@gebeer

v1.0.121: nested pi --help spawns orphaned context-mode MCP servers that spin at 100% CPU

Summary

On Linux/Pi with context-mode@1.0.121, running short-lived nested pi commands from inside an active Pi session can leave orphaned context-mode/server.bundle.mjs Bun processes spinning at 100% CPU. The processes ignored SIGTERM and required SIGKILL.

This appears related to #388/#311, but reproduced on v1.0.121 through Pi package auto-loading.

Environment

  • OS: Arch Linux
  • Host: Pi Coding Agent
  • context-mode: 1.0.121
  • Runtime: Bun via /home/gbr/.bun/bin/bun
  • Pi config includes npm:context-mode in ~/.pi/agent/settings.json packages.

Relevant settings:

"packages": [
  "npm:pi-extmgr",
  "npm:pi-web-access",
  "npm:pi-mcp-adapter",
  {
    "source": "npm:pi-hosts",
    "extensions": ["-dist/index.js"]
  },
  "npm:context-mode"
]

Trigger

From inside an active Pi session, the agent ran:

pi --help 2>&1 | head -80
pi --help 2>&1 | tail -80

These short-lived nested Pi invocations appear to auto-load npm:context-mode, start MCP servers, then exit quickly.

Observed result

Immediately after the commands, two MCP ready files appeared:

/tmp/context-mode-mcp-ready-42366
/tmp/context-mode-mcp-ready-42413

Corresponding processes:

42366 /home/gbr/.bun/bin/bun /home/gbr/.nvm/versions/node/v24.14.1/lib/node_modules/context-mode/server.bundle.mjs
42413 /home/gbr/.bun/bin/bun /home/gbr/.nvm/versions/node/v24.14.1/lib/node_modules/context-mode/server.bundle.mjs

Both were in Rl state and pegged at ~100% CPU each:

PID    PPID STAT %CPU COMMAND
42366  1391 Rl   100  bun .../context-mode/server.bundle.mjs
42413  1391 Rl   100  bun .../context-mode/server.bundle.mjs

PPID=1391 was systemd --user, so they had become orphaned.

kill / SIGTERM did not stop them. kill -KILL was required.

Expected

Short-lived nested Pi commands such as pi --help should not leave orphaned context-mode MCP servers, and MCP server children should exit cleanly when the parent Pi process exits.

Reproduction

From inside an active Pi session:

# snapshot baseline
pgrep -f 'context-mode/server.bundle' | sort

# trigger
pi --help 2>&1 | head -5
pi --help 2>&1 | tail -5

# check for new orphans
pgrep -f 'context-mode/server.bundle' | sort   # expect 2 new PIDs
ps -p <new_pid1>,<new_pid2> -o pid,ppid,stat,%cpu
# → PPID=systemd, Rl state, ~100% CPU

# confirm SIGTERM is ignored
kill <new_pid1> <new_pid2>; sleep 1
ps -p <new_pid1>,<new_pid2> -o pid,stat   # still alive
kill -9 <new_pid1> <new_pid2>              # SIGKILL required

Reproduced on 2026-05-12 with the exact same symptoms.

Notes

This looks similar to #388/#311, but still occurs on 1.0.121 through the nested-Pi path. It may be a remaining lifecycle gap when Pi auto-loads context-mode for short-lived invocations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions