claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Hook Configuration Progressive Duplication Causing Performance Issues

Open V-Andriy opened this issue 1 year ago • 6 comments

Summary

Claude Code hooks progressively duplicate during sessions, causing multiple simultaneous executions (up to 10+ ESLint processes) after each file edit, resulting in severe performance degradation.

Environment

  • Claude Code Version: v1.0.51
  • OS: macOS (Darwin 24.5.0)
  • Platform: PNPM-based Next.js 15 project
  • Config Location: .claude/settings.local.json

Problem Description

  1. Progressive Duplication: Hooks gradually multiply over time during active Claude Code sessions
  2. Performance Impact: Multiple ESLint processes run simultaneously (observed up to 10 instances)
  3. Resource Consumption: High CPU/memory usage from duplicate processes
  4. Workflow Disruption: Significant slowdown during file editing operations

Steps to Reproduce

  1. Configure PostToolUse hooks for ESLint checking
  2. Use Claude Code for extended file editing session
  3. Observe progressive increase in hook execution time
  4. Check system processes during file edits - multiple ESLint instances running

Expected Behavior

Single hook execution per configured trigger event.

Actual Behavior

Multiple identical hook executions (2x, 5x, 10x+) for single trigger event, increasing over session duration.

Current Configuration (After Manual Cleanup)

{ "hooks": { "PostToolUse": [ { "matcher": "Edit|Write|MultiEdit", "hooks": [ { "type": "command", "command": "python3 '/path/to/eslint_check.py'" } ] } ] } }

Workaround

Manual cleanup of configuration file and Claude Code session restart.

Suspected Root Cause

Hook registry not properly cleared between operations, leading to accumulation of hook configurations in memory.

V-Andriy avatar Jul 15 '25 07:07 V-Andriy

+1 getting the same behavior. PreTool Hook is getting duplicated and eventually causes Claude Code to stop working when trying to process hooks. Can't find a clear cause of the duplication. I can watch hooks get called without a duplicate being added to the settings.local.json, but other times I look and I have 100s of the same hook.

Soljourner avatar Jul 15 '25 16:07 Soljourner

I can confirm, I also have the same issue on version 1.0.52, got a 16k+ stop hooks at one point

funCapital avatar Jul 16 '25 07:07 funCapital

I noticed the same phenomenon. I am using VSCode on Ubuntu Server via SSH from MacOS.

Environment

Claude Code Version: v1.0.53
OS: macOS (Darwin 24.5.0) / Ubuntu 22.04 on GCE Instance
Node version: v22.5.1
Config Location: .claude/settings.local.json

After looking into the settings in detail, it appears that each hook is being duplicated 64 times.

Image

Unfortunately, this setting is not managed by git, so it is unclear when it was duplicated. If my memory is correct, MaxListenersExceededWarning started appearing on Monday of this week when using claude code.

OldBigBuddha avatar Jul 17 '25 02:07 OldBigBuddha

This regression was fixed in v1.0.53 in that /hooks will no longer duplicate configs. However, you will need to manually clean up your settings file due to the regression.

I am adding a fix in the next release v1.0.56 that will deduplicate the hooks commands when reading settings files that have duplicates, but you should still clean up the settings file.

dicksontsai avatar Jul 18 '25 00:07 dicksontsai

The deduplication logic is now deployed.

dicksontsai avatar Jul 24 '25 22:07 dicksontsai

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Aug 01 '25 14:08 github-actions[bot]