/reload-plugins throws TypeError: P?.reduce is not a function despite successful reload

Resolved 💬 3 comments Opened Apr 14, 2026 by therealDimitri Closed Apr 17, 2026

Version: Claude Code 2.1.107 (native binary, macOS Darwin 25.4.0)

What happens

Running /reload-plugins reports:

TypeError: P?.reduce is not a function. (In 'P?.reduce((X,R)=>X+R.hooks.length,0)', 'P?.reduce' is undefined)

What actually works

The reload itself succeeds. After the error is shown, new plugins appear in the available skills list and their MCP tools become callable (verified by observing nimble skills and nimble-mcp-server tools appear after installing a new plugin and running /reload-plugins). The error is thrown by what appears to be the success-summary code that aggregates total hook counts across loaded plugins.

Likely root cause

The optional chaining P?.reduce only guards against null/undefined. If P is an object (not an array), P?.reduce evaluates to undefined and calling it throws. The plugins field in ~/.claude/plugins/installed_plugins.json is serialised as an object keyed by plugin@marketplace (not an array), so any code path that consumes it expecting an array will fail at this line.

Reproduction

  1. Have ≥1 plugin installed so installed_plugins.json has a non-empty plugins object
  2. Run /reload-plugins

Environment

  • Claude Code 2.1.107 (native binary via ~/.local/bin/claude)
  • macOS Darwin 25.4.0
  • 77 installed plugins across 10 marketplaces
  • Also reproduced after cleaning up stale plugin install paths (not cause-related)

Suggested fix

Either coerce the plugins collection to an array before reducing (Object.values(P)?.reduce(...)) or guard with Array.isArray(P) ? P.reduce(...) : 0.

View original on GitHub ↗

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