Skip to content

Bug: agentcore dev leaves orphaned Uvicorn process on Ctrl+C #1690

Description

@madhavvishnubhatta

Description

Summary

When stopping agentcore dev --logs with Ctrl+C, the CLI's Node process exits but does not terminate the Uvicorn subprocess it spawned. The Uvicorn process (and its children) become orphaned under PID 1 and continue running indefinitely, holding the port. This happens every time, not intermittently.

Impact

  • The orphaned server retains in-memory state (e.g., Strands Agent conversation history), making it appear that sessions persist across restarts.
  • On next agentcore dev start, the port is occupied, forcing fallback to a different port (e.g., 8081).
  • The CLI may still route prompts to the old port, talking to the stale server instance without the user's knowledge.
  • Accumulated orphaned processes consume system resources.

Steps to Reproduce

  1. Start the dev server:

    agentcore dev --no-browser --logs
  2. Confirm the process tree:

    ps -ef | grep uvicorn
    # Shows: agentcore (node) → uvicorn reloader → uvicorn worker
  3. Press Ctrl+C in the terminal running agentcore dev.

  4. Verify the orphaned processes:

    lsof -i :8080
    # Uvicorn processes still listening on the port
    
    ps -ef | grep <uvicorn_pid>
    # PPID is now 1 (orphaned under launchd/init)

Expected Behavior

Expected behaviour is that the Uvicorn process listening on 8080 is also killed.

Actual Behavior

Ctrl+C should terminate both the agentcore CLI process and the entire Uvicorn subprocess tree cleanly, releasing the port.

CLI Version

0.22.0

Operating System

macOS

Additional Context

Observed Process Tree

Before Ctrl+C:

PID 15652  node /opt/homebrew/bin/agentcore dev --no-browser --logs   (PPID: 7376, shell)
  PID 15656  python3 ... uvicorn main:app --reload --host 127.0.0.1 --port 8080   (PPID: 15652)
    PID 15657  python3 ... multiprocessing.resource_tracker   (PPID: 15656)
    PID 15658  python3 ... multiprocessing.spawn              (PPID: 15656)

After Ctrl+C:

PID 15652  — GONE (agentcore node process exited)
PID 15656  python3 ... uvicorn ... --port 8080   (PPID: 1, orphaned under launchd)
  PID 15657  python3 ... resource_tracker          (PPID: 15656)
  PID 15658  python3 ... spawn                     (PPID: 15656)

Workaround (for users)

Until the fix is released, users can work around this by manually killing orphaned processes:

# Kill any process on port 8080
lsof -ti :8080 | xargs kill

# Or use SIGQUIT instead of SIGINT (more forceful)
# Press Ctrl+\ instead of Ctrl+C

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions