Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test: preserve the held-file race in Windows artifact recovery (#2383)

Michael D'Angelo69c85b6cb1f2
diff --git a/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts b/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts
index 8424f4282..eb2e32bdc 100644
--- a/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts
+++ b/plugins/codex-security/mcp-app/tests/test_artifact_scan_draft_recovery.ts
@@ -531,8 +531,13 @@ for (const observation of ["checkpoint head", "worker result"]) {
let replaced = false;
const replaceOnce = async (destination: string) => {
if (replaced) return;
- replaced = true;
+ // Windows can move the open result aside, but cannot overwrite its name.
+ // Keep its original handle open while the pathname acquires the new mtime.
+ if (process.platform === "win32" && destination === resultPath) {
+ await rename(resultPath, path.join(f.root, "previous-result.json"));
+ }
await rename(replacementPath, destination);
+ replaced = true;
};
const originalLstat = fsPromises.lstat;
const originalReadFile = fsPromises.readFile;