fix(FN-4948): harden guard install failure cleanup paths

Fusion-Task-Id: FN-4948
Fusion-Task-Lineage: dc622643-4c3e-4217-9219-a6a6e5424427
This commit is contained in:
Fusion (runfusion.ai)
2026-05-17 13:31:54 -07:00
committed by gsxdsm
parent 487dfcc10c
commit 4b16429618
5 changed files with 80 additions and 13 deletions

View File

@@ -1346,10 +1346,19 @@ Follow instructions precisely and avoid unrelated changes.`,
throw err;
}
await installTaskWorktreeIdentityGuard({
worktreePath,
taskId: this.options.taskDetail.id,
});
try {
await installTaskWorktreeIdentityGuard({
worktreePath,
taskId: this.options.taskDetail.id,
});
} catch (err) {
try {
await execAsync(`rm -rf "${worktreePath}"`, { cwd: rootDir, env: this.options.taskEnv });
} catch {
stepExecLog.log(`Warning: failed to remove worktree after identity-guard install failure: ${worktreePath}`);
}
throw err;
}
this.registerParallelWorktree(stepIndex, worktreePath);
this.parallelBranches.set(stepIndex, branchName);