From 02fc0359bb02996218e0d896c1f347d19cd2f0bf Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Tue, 1 Sep 2026 12:53:17 -0400 Subject: [PATCH] fix(test): publish process markers atomically --- .../scripts/run-agent-task/execute-native-agent-task.mjs | 6 ++++-- tests/fixtures/playground-cache-lease-child.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/scripts/run-agent-task/execute-native-agent-task.mjs b/.github/scripts/run-agent-task/execute-native-agent-task.mjs index fc9abcdc4..4848acb68 100644 --- a/.github/scripts/run-agent-task/execute-native-agent-task.mjs +++ b/.github/scripts/run-agent-task/execute-native-agent-task.mjs @@ -1,5 +1,5 @@ import { constants, rmSync } from "node:fs" -import { appendFile, lstat, mkdir, open, readFile, realpath, rm, writeFile } from "node:fs/promises" +import { appendFile, lstat, mkdir, open, readFile, realpath, rename, rm, writeFile } from "node:fs/promises" import { isUtf8 } from "node:buffer" import { isAbsolute, join, relative, resolve } from "node:path" import { pathToFileURL } from "node:url" @@ -523,7 +523,9 @@ async function testPauseAfterSeedSnapshot(seedSnapshot) { if (process.env.NODE_ENV !== "test") return const markerPath = string(process.env.WP_CODEBOX_TEST_SEED_SNAPSHOT_PAUSE_FILE) if (!markerPath) return - await writeFile(markerPath, `${JSON.stringify({ schema: "wp-codebox/test-seed-snapshot-pause/v1", seed_snapshot_source: seedSnapshot?.source ?? "" })}\n`) + const pendingMarkerPath = `${markerPath}.${process.pid}.tmp` + await writeFile(pendingMarkerPath, `${JSON.stringify({ schema: "wp-codebox/test-seed-snapshot-pause/v1", seed_snapshot_source: seedSnapshot?.source ?? "" })}\n`) + await rename(pendingMarkerPath, markerPath) await new Promise((resolvePause) => setTimeout(resolvePause, 120_000)) } diff --git a/tests/fixtures/playground-cache-lease-child.ts b/tests/fixtures/playground-cache-lease-child.ts index 8ce3ea699..9df30cccb 100644 --- a/tests/fixtures/playground-cache-lease-child.ts +++ b/tests/fixtures/playground-cache-lease-child.ts @@ -1,4 +1,4 @@ -import { lstat, writeFile } from "node:fs/promises" +import { lstat, rename, writeFile } from "node:fs/promises" import { acquirePlaygroundArchiveReference } from "../../packages/runtime-playground/src/playground-wordpress-archive-cache.js" @@ -8,7 +8,9 @@ if (!archivePath || !readyPath || !stopPath) { } const reference = await acquirePlaygroundArchiveReference(archivePath) -await writeFile(readyPath, reference.path) +const pendingReadyPath = `${readyPath}.${process.pid}.tmp` +await writeFile(pendingReadyPath, reference.path) +await rename(pendingReadyPath, readyPath) while (!await exists(stopPath)) { await new Promise((resolve) => setTimeout(resolve, 25))