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
-
Start the dev server:
agentcore dev --no-browser --logs
-
Confirm the process tree:
ps -ef | grep uvicorn
# Shows: agentcore (node) → uvicorn reloader → uvicorn worker
-
Press Ctrl+C in the terminal running agentcore dev.
-
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
Description
Summary
When stopping
agentcore dev --logswith 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
agentcore devstart, the port is occupied, forcing fallback to a different port (e.g., 8081).Steps to Reproduce
Start the dev server:
Confirm the process tree:
Press Ctrl+C in the terminal running
agentcore dev.Verify the orphaned processes:
Expected Behavior
Expected behaviour is that the Uvicorn process listening on 8080 is also killed.
Actual Behavior
Ctrl+C should terminate both the
agentcoreCLI 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:
After Ctrl+C:
Workaround (for users)
Until the fix is released, users can work around this by manually killing orphaned processes: