Skip to content

Commit a7b2aa6

Browse files
committed
🤖 fix: wait for plan file deletion
deletePlanFilesForWorkspace() used runtime.exec() without waiting for completion.\nAwait stdin.close() + exitCode so callers can assume plan files are gone when it resolves.\n\n_Generated with mux_
1 parent d41c317 commit a7b2aa6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/node/services/workspaceService.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,12 +1087,25 @@ export class WorkspaceService extends EventEmitter {
10871087
});
10881088

10891089
try {
1090-
// Use exec to delete files since runtime doesn't have a deleteFile method
1091-
// Delete both paths in one command for efficiency
1092-
await runtime.exec(`rm -f ${quotedPlanPath} ${quotedLegacyPlanPath}`, {
1090+
// Use exec to delete files since runtime doesn't have a deleteFile method.
1091+
// Delete both paths in one command for efficiency.
1092+
//
1093+
// IMPORTANT: runtime.exec() returns streams immediately; we must wait for completion
1094+
// so callers can safely assume the plan file is gone when this function resolves.
1095+
const stream = await runtime.exec(`rm -f ${quotedPlanPath} ${quotedLegacyPlanPath}`, {
10931096
cwd: metadata.projectPath,
10941097
timeout: 10,
10951098
});
1099+
1100+
try {
1101+
await stream.stdin.close();
1102+
} catch {
1103+
// Ignore stdin-close errors (e.g. already closed).
1104+
}
1105+
1106+
await stream.exitCode.catch(() => {
1107+
// Best-effort: ignore failures.
1108+
});
10961109
} catch {
10971110
// Plan files don't exist or can't be deleted - ignore
10981111
}

0 commit comments

Comments
 (0)