[BUG] Crash in permission prompt flow involving @withfig/autocomplete dynamic import

Resolved 💬 2 comments Opened Apr 17, 2026 by mrrobotke Closed Apr 18, 2026

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 BysPHovsPH).

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_6tI5$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 sPHov 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 the aI5 set, or commands whose args[i].isCommand is true) that trigger the recursive branch in tI5.
  • No recovery — the whole CLI process exits.

Suggested investigation

  1. Wrap the dynamic import('@withfig/autocomplete/build/${H}.js') in a try/catch that returns null on failure instead of propagating. The outer try/catch exists, but something in the awaited module evaluation may be throwing after the catch boundary.
  2. Verify the memoization wrapper hM around $mH is not caching a rejected promise that then re-throws on every subsequent lookup for the same command name.
  3. Add defensive handling in tI5/L_6 so a throw from $mH does 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗