From 15b0627259e14184ac8b731ae9c4ba647cdec074 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Fri, 13 Feb 2026 17:30:29 -0800 Subject: [PATCH] fix: kill orphaned terminal daemon processes during worktree teardown Electron terminal-host and pty-subprocess processes spawned from a worktree's node_modules persist after the worktree is deleted. Add a teardown step that finds and kills these processes by matching the worktree path before the directory is removed. --- .superset/teardown.sh | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/.superset/teardown.sh b/.superset/teardown.sh index c55182d720c..e049943743c 100755 --- a/.superset/teardown.sh +++ b/.superset/teardown.sh @@ -110,6 +110,32 @@ step_check_dependencies() { return 0 } +step_kill_terminal_daemons() { + echo "🔪 Killing terminal daemon processes..." + + local worktree_path + worktree_path="$(pwd)" + local killed=0 + + for pattern in "terminal-host.js" "pty-subprocess.js"; do + local pids + pids=$(pgrep -f "${worktree_path}/.*${pattern}" 2>/dev/null || true) + if [ -n "$pids" ]; then + for pid in $pids; do + kill "$pid" 2>/dev/null && ((killed++)) || true + done + fi + done + + if [ "$killed" -gt 0 ]; then + success "Killed $killed terminal daemon process(es)" + else + success "No terminal daemon processes found" + fi + + return 0 +} + step_stop_electric() { echo "⚡ Stopping Electric SQL container..." @@ -195,12 +221,17 @@ main() { # Step 2: Check dependencies (informational only) step_check_dependencies - # Step 3: Stop Electric SQL + # Step 3: Kill terminal daemons + if ! step_kill_terminal_daemons; then + step_failed "Kill terminal daemons" + fi + + # Step 4: Stop Electric SQL if ! step_stop_electric; then step_failed "Stop Electric SQL" fi - # Step 4: Delete Neon branch + # Step 5: Delete Neon branch if ! step_delete_neon_branch; then step_failed "Delete Neon branch" fi