Claude Code doesn't detect when `npm run start:dev` finishes and hangs indefinitely

Resolved 💬 5 comments Opened Jul 25, 2025 by adbertram Closed Feb 1, 2026

Bug Description

When running npm run start:dev in Claude Code, the CLI doesn't detect that the process has finished executing and hangs indefinitely. This prevents Claude Code from proceeding with subsequent commands or providing feedback to the user that the script has completed.

Expected Behavior

Claude Code should detect when npm scripts complete execution and return control to the user, allowing for subsequent commands to be run.

Actual Behavior

After running npm run start:dev, Claude Code appears to hang indefinitely, not recognizing that the npm script has finished. The user has to manually interrupt (Ctrl+C) to regain control.

Possible Causes

  1. Process detection issue: Claude Code may not be properly detecting when child processes spawned by npm scripts terminate
  2. Output stream handling: The script might be keeping stdout/stderr streams open even after completion
  3. Signal handling: The process completion signal might not be properly propagated to Claude Code

Suggested Solutions

  1. Implement proper process exit detection for npm scripts, including checking for:
  • Process exit codes
  • Closed stdout/stderr streams
  • Child process termination signals
  1. Add a timeout mechanism specifically for development server scripts that typically run indefinitely (like start:dev)
  1. Provide clear visual feedback when a long-running process is detected, with options to:
  • Continue running in background
  • Terminate the process
  • Detach from the process

Workaround

Currently, users must manually interrupt the hanging process with Ctrl+C to regain control of Claude Code.

Related Issues

This appears to be a new issue not covered by existing hanging/freeze issues (#3723, #3775, #3790, etc.) which seem to focus on general command execution problems rather than npm script completion detection.

View original on GitHub ↗

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