feat: clean up all tasks before exit

This commit is contained in:
d-kimsuon
2025-09-03 03:44:43 +09:00
parent d9a0f17ce7
commit 31da82377d
3 changed files with 17 additions and 0 deletions

View File

@@ -50,6 +50,7 @@
"jotai": "^2.13.1",
"lucide-react": "^0.542.0",
"next": "15.5.2",
"prexit": "^2.3.0",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-error-boundary": "^6.0.0",

9
pnpm-lock.yaml generated
View File

@@ -56,6 +56,9 @@ importers:
next:
specifier: 15.5.2
version: 15.5.2(react-dom@19.1.1(react@19.1.1))(react@19.1.1)
prexit:
specifier: ^2.3.0
version: 2.3.0
react:
specifier: ^19.1.1
version: 19.1.1
@@ -2681,6 +2684,10 @@ packages:
resolution: {integrity: sha512-4yf0QO/sllf/1zbZWYnvWw3NxCQwLXKzIj0G849LSufP15BXKM0rbD2Z3wVnkMfjdn/CB0Dpp444gYAACdsplg==}
engines: {node: '>=18'}
prexit@2.3.0:
resolution: {integrity: sha512-mX+LIbtS0anKtl2PykYabxninwloblUQMRO6CubeSmjxb+kKlATuJoH9UeN8NLE4TgIEFWfBXw7V3GkWbBrSmg==}
engines: {node: '>=12'}
prismjs@1.27.0:
resolution: {integrity: sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==}
engines: {node: '>=6'}
@@ -5766,6 +5773,8 @@ snapshots:
dependencies:
parse-ms: 4.0.0
prexit@2.3.0: {}
prismjs@1.27.0: {}
prismjs@1.30.0: {}

View File

@@ -1,6 +1,7 @@
import { execSync } from "node:child_process";
import { query } from "@anthropic-ai/claude-code";
import { ulid } from "ulid";
import prexit from "prexit";
import { type EventBus, getEventBus } from "../events/EventBus";
import { createMessageGenerator } from "./createMessageGenerator";
import type {
@@ -20,6 +21,12 @@ export class ClaudeCodeTaskController {
.toString()
.trim();
this.eventBus = getEventBus();
prexit(() => {
this.aliveTasks.forEach((task) => {
task.abortController.abort();
});
});
}
public get aliveTasks() {