[BUG] Crash in permission prompt flow involving @withfig/autocomplete dynamic import
Describe the bug
Claude Code crashes intermittently with a stack trace originating in the command-prefix / autocomplete resolution path that runs during the tool permission prompt flow. The crash surfaces while rendering/processing a tool use permission request (chain through By → sPH → ov → sPH).
The failing call site is a dynamic import of @withfig/autocomplete:
import(`@withfig/autocomplete/build/${H}.js`)
…inside the function chain that parses command prefixes (L_6 → tI5 → $mH) when evaluating whether a Bash command should be auto-approved against permission rules.
Environment
- Claude Code version: 2.1.112
- OS: macOS (Darwin 25.3.0)
- Shell: zsh
- Install: Bun-bundled CLI (
/$bunfs/root/src/entrypoints/cli.js)
Stack trace (relevant portion)
- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:8231:15642)
- qX (/$bunfs/root/src/entrypoints/cli.js:477:63169)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76220)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
- sPH (/$bunfs/root/src/entrypoints/cli.js:477:76199)
- ov (/$bunfs/root/src/entrypoints/cli.js:477:76101)
The repeating sPH ↔ ov frames suggest recursion through the command-prefix resolver (L_6 calling tI5 which calls L_6 again for sub-commands). The recursion guard is q > 2 || _ > 10, but something inside the dynamic import() (or its memoized wrapper $mH) is throwing in a way that is not caught cleanly.
Relevant code (from the bundle)
import(`@withfig/autocomplete/build/${H}.js`);
// …wrapped by:
$mH = hM(async (H) => {
return Bf8.find((q) => q.name === H) || await rI5(H) || null
}, (H) => H);
async function L_6(H, _ = 0, q = 0) {
if (q > 2 || _ > 10) return null;
// …parses command, calls tI5 (which recurses into L_6) and $mH
}
function By(H, _) {
// Permission prompt hook — fires tengu_tool_use_show_permission_request
// and calls a0({ completion_type: _.completion_type, event: "response", ... })
}
Expected behavior
The permission prompt should render without crashing the CLI, even if the @withfig/autocomplete dynamic import fails for a particular command name or the command-prefix resolver hits an edge case.
Observations
- Happens repeatedly during normal tool use sessions (not on a specific command I can isolate yet).
- Appears correlated with Bash tool permission prompts where the proposed command has nested/compound sub-commands (e.g.
nice <cmd>, commands in theaI5set, or commands whoseargs[i].isCommandis true) that trigger the recursive branch intI5. - No recovery — the whole CLI process exits.
Suggested investigation
- Wrap the dynamic
import('@withfig/autocomplete/build/${H}.js')in a try/catch that returnsnullon failure instead of propagating. The outertry/catchexists, but something in the awaited module evaluation may be throwing after the catch boundary. - Verify the memoization wrapper
hMaround$mHis not caching a rejected promise that then re-throws on every subsequent lookup for the same command name. - Add defensive handling in
tI5/L_6so a throw from$mHdoes not bubble out of the permission-prompt render path (By/v_6).
Happy to provide more context or a reproduction if pointers on how to capture a fuller trace would help.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗