Bug: Infinite recursion (OOM) when passing arguments to /gsd discuss, queue, visualize, or inspect
Problem
When a user runs /gsd discuss M001/S02 (or uses natural language that maps to it like talk about M001/S02), the application crashes with a "JavaScript heap out of memory" error due to infinite recursion in the command dispatcher.
Root Cause
In commands/dispatcher.js, if a command isn't matched by any specific handler (because of the extra arguments), it falls back to handleDo() in commands-do.js.
handleDo() maps natural language to commands. For "discuss M001/S02", it matches the "discuss" keyword, extracts the remaining arguments "M001/S02", and re-dispatches the exact same string "discuss M001/S02" back to handleGSDCommand().
Because the handler in commands/handlers/workflow.js strictly checks trimmed === "discuss" (without trimmed.startsWith), it rejects the command again, sending it back to handleDo(). This infinite loop of promise allocations quickly exhausts the heap.
Vulnerable commands: discuss, queue, visualize, inspect.
Code snippet (commands/handlers/workflow.js)
if (trimmed === "discuss") { // Fails on "discuss M001/S02"
if (requireNotAutoActive("/gsd discuss", ctx))
return true;
await showDiscuss(ctx, pi, projectRoot());
return true;
}Code snippet (commands-do.js)
const match = matchRoute(args);
if (match) {
const fullCommand = match.remainingArgs
? `${match.command} ${match.remainingArgs}`
: match.command;
// When args == "discuss M001/S02", fullCommand is identically "discuss M001/S02".
// Re-dispatching this causes infinite recursion.
const { handleGSDCommand } = await import("./commands/dispatcher.js");
await handleGSDCommand(fullCommand, ctx, pi);
return;
}Expected Behavior
- Update
commands-do.jsto break the loop. IffullCommand === args, it means mapping the natural language command didn't yield a different string, so re-dispatching will definitely loop. In that case, either dispatchmatch.commandwithout args, or show an error. - Update the strict command handlers to accept trailing arguments so they capture the routing properly:
if (trimmed === "discuss" || trimmed.startsWith("discuss ")) { // handle }
Environment
- GSD version: 3.0.0
- Model: gemini-3.1-pro-low
- Unit: Commands / Dispatcher
Reproduction Context
The user tried to discuss a specific slice (discuss M001/S02) via the command line or natural language. The command hit the dispatcher fallback logic and triggered the infinite loop.
Forensic Evidence
- The process crash lock left behind indicates the crash brought down the entire auto-mode worker process abruptly without a clean exit.
execute-task M001/S02/T02was logged in the crash lock merely because the command loop runs in the same node process, or the user invoked it during an interactive pause.
Auto-generated by /gsd forensics
Source: gsd-build/gsd-2