fix: resolve task timeout bug and refactor remote executor wait logic

- Prevent hardcoded 30-minute timeout when timeout is set to 0.
- Fix zombie processes by actively stopping tasks during deletion.
- Refactor remote execution wait logic to properly handle ctx.Done() and agent disconnections.
This commit is contained in:
duorameng
2026-06-12 17:00:55 +08:00
parent 626d20c9b8
commit 5626873454
3 changed files with 74 additions and 29 deletions
+7 -3
View File
@@ -112,10 +112,14 @@ func ExecuteWithHooks(ctx context.Context, req Request, stdout, stderr io.Writer
// 2. 执行命令
timeout := req.Timeout
if timeout <= 0 {
timeout = 30
var execCtx context.Context
var cancel context.CancelFunc
if timeout > 0 {
execCtx, cancel = context.WithTimeout(ctx, time.Duration(timeout)*time.Minute)
} else {
execCtx, cancel = context.WithCancel(ctx)
}
execCtx, cancel := context.WithTimeout(ctx, time.Duration(timeout)*time.Minute)
defer cancel()
// 如果指定使用 mise,则预先构建好带 mise 的命令,这样 PreExecute 记录的就是完整命令