fix: clean up tmux session when launch command send-keys fails
If send-keys fails after new-session succeeds, the orphaned tmux session was left running and unmanaged. Now wraps send-keys in try/catch that kills the session before rethrowing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
323fd2da21
commit
09e1a85b1c
|
|
@ -54,8 +54,20 @@ export function create(): Runtime {
|
|||
// Create tmux session in detached mode
|
||||
await tmux("new-session", "-d", "-s", sessionName, "-c", config.workspacePath, ...envArgs);
|
||||
|
||||
// Send the launch command
|
||||
await tmux("send-keys", "-t", sessionName, config.launchCommand, "Enter");
|
||||
// Send the launch command — clean up the session if this fails
|
||||
try {
|
||||
await tmux("send-keys", "-t", sessionName, config.launchCommand, "Enter");
|
||||
} catch (err: unknown) {
|
||||
try {
|
||||
await tmux("kill-session", "-t", sessionName);
|
||||
} catch {
|
||||
// Best-effort cleanup
|
||||
}
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
throw new Error(`Failed to send launch command to session "${sessionName}": ${msg}`, {
|
||||
cause: err,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
id: sessionName,
|
||||
|
|
|
|||
Loading…
Reference in New Issue