Platform
OpenClaw (Pi Agent)
context-mode version
latest as of 2026-06-12
Debug script output (REQUIRED)
Active handles: 6
Handle 0: Socket fd=1 (stdout) ← normal
Handle 1: Socket fd=2 (stderr) ← normal
Handle 2: Socket fd=26 ← MCP bridge pipe
Handle 3: Socket fd=28 ← MCP bridge pipe
Handle 4: Socket fd=30 ← MCP bridge pipe
Handle 5: ChildProcess pid=126705 ← THE CULPRIT
args=["/usr/bin/node",".../context-mode/server.bundle.mjs"]
closesNeeded=3
=== DETECTED: Spawning server.bundle.mjs ===
command: /usr/bin/node
args: /home/chagwood/.pi/agent/npm/node_modules/context-mode/server.bundle.mjs
argv[2]: install
isPiShortCircuitArgv would return: false
pi version: 0.79.2
OS: Linux (x86_64)
Node.js: /usr/bin/node
Exact prompt that triggered the bug (REQUIRED)
pi install npm:pi-subagents
Full error output (REQUIRED)
The command prints:
Installing npm:pi-subagents...
...
Installed npm:pi-subagents
...and then the terminal hangs indefinitely. Ctrl+C is required to exit.
Root cause: The Pi extension in build/adapters/pi/extension.js has a short-circuit guard (PI_SHORT_CIRCUIT_TOKENS) that skips spawning the MCP server for --help and --version, but install/uninstall/remove/update/list/config are NOT in the short-circuit set.
The MCP bridge spawns server.bundle.mjs as a child process with piped stdio:
this.child = spawn(runtime, [this.serverScript], { stdio: ["pipe", "pipe", "pipe"], env: childEnv });
When pi install finishes, main() returns, but the child process is still alive with 3 open pipes. Node.js refuses to exit because there is still an active ChildProcess handle in the event loop.
The cleanup path (session_shutdown handler) calls _mcpBridge.shutdown() which sends SIGTERM — but that event only fires during interactive session shutdown, never for pi install.
process._getActiveHandles() 6 seconds after install completes:
Handle 5: ChildProcess pid=126705
args=["/usr/bin/node",".../context-mode/server.bundle.mjs"]
closesNeeded=3
Steps to reproduce (REQUIRED)
- Run:
pi install npm:pi-subagents
- Observe the success message is printed:
Installing npm:pi-subagents...
...
Installed npm:pi-subagents
- The terminal hangs indefinitely after the success message
- Ctrl+C is required to exit
- The process never exits on its own
The issue is reproducible with any pi install command (also uninstall, remove, update, list, config).
What have you tried to fix it?
Root cause identified: The Pi extension in build/adapters/pi/extension.js has a short-circuit guard (PI_SHORT_CIRCUIT_TOKENS) that skips spawning the MCP server for --help and --version, but package management subcommands (install, uninstall, remove, update, list, config) are NOT in the short-circuit set.
The MCP bridge spawns server.bundle.mjs via bootstrapMCPTools() as a child process with piped stdio. When pi install finishes, main() returns, but the child process is still alive with 3 open pipes. Node.js refuses to exit because there is still an active ChildProcess handle in the event loop.
The cleanup path (session_shutdown handler) calls _mcpBridge.shutdown() which sends SIGTERM — but that event only fires during interactive session shutdown, never for pi install.
Proposed fix: Add the package management subcommands to PI_SHORT_CIRCUIT_TOKENS:
// Before:
const PI_SHORT_CIRCUIT_TOKENS = new Set(["--help", "-h", "--version", "-v", "help"]);
// After:
const PI_SHORT_CIRCUIT_TOKENS = new Set([
"--help", "-h", "--version", "-v", "help",
"install", "uninstall", "remove", "update", "list", "config",
]);
Verification after applying fix locally:
| Metric |
Before |
After |
| Exits? |
Hangs forever |
Clean exit |
| Exit code |
124 (killed by timeout) |
0 |
| Time |
infinity |
~3.5s |
| server.bundle.mjs spawned |
Yes (unnecessary) |
No |
Related: Issue #534 fixed the same class of problem for --help/--version but missed the package management subcommands.
Pre-submission checklist
Operating System
Linux (Ubuntu/Debian)
JS Runtime
22.22.1
Platform
OpenClaw (Pi Agent)
context-mode version
latest as of 2026-06-12
Debug script output (REQUIRED)
Exact prompt that triggered the bug (REQUIRED)
Full error output (REQUIRED)
Steps to reproduce (REQUIRED)
pi install npm:pi-subagentsThe issue is reproducible with any
pi installcommand (alsouninstall,remove,update,list,config).What have you tried to fix it?
Root cause identified: The Pi extension in
build/adapters/pi/extension.jshas a short-circuit guard (PI_SHORT_CIRCUIT_TOKENS) that skips spawning the MCP server for--helpand--version, but package management subcommands (install,uninstall,remove,update,list,config) are NOT in the short-circuit set.The MCP bridge spawns
server.bundle.mjsviabootstrapMCPTools()as a child process with piped stdio. Whenpi installfinishes,main()returns, but the child process is still alive with 3 open pipes. Node.js refuses to exit because there is still an activeChildProcesshandle in the event loop.The cleanup path (
session_shutdownhandler) calls_mcpBridge.shutdown()which sends SIGTERM — but that event only fires during interactive session shutdown, never forpi install.Proposed fix: Add the package management subcommands to
PI_SHORT_CIRCUIT_TOKENS:Verification after applying fix locally:
Related: Issue #534 fixed the same class of problem for
--help/--versionbut missed the package management subcommands.Pre-submission checklist
Operating System
Linux (Ubuntu/Debian)
JS Runtime
22.22.1