From a5761c7545f6e0a5c6ddefc10bd4ea8d99ee33a4 Mon Sep 17 00:00:00 2001 From: ShuaixinHuang <197200901+ShuaixinHuang@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:34:25 +0000 Subject: [PATCH] test(kuna): bound lifecycle acknowledgements through shared owner --- .../kuna/kunaProjectConcurrency.test.ts | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/tests/boundary/providers/kuna/kunaProjectConcurrency.test.ts b/tests/boundary/providers/kuna/kunaProjectConcurrency.test.ts index 25255a2db3..7d7d979bed 100644 --- a/tests/boundary/providers/kuna/kunaProjectConcurrency.test.ts +++ b/tests/boundary/providers/kuna/kunaProjectConcurrency.test.ts @@ -9,6 +9,7 @@ import { inspectKunaInstallationOwned as inspectKunaInstallation } from "./kunaR import { KunaProjectCache } from "../../../../src/kuna/KunaProjectCache.js"; import type { KunaExportStatus } from "../../../../src/kuna/KunaProjectExport.js"; import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js"; +import { awaitAcknowledgement } from "../../../fixtures/lifecycleAcknowledgement.js"; import { fakeKunaCalls, writeFakeKuna } from "./fakeKuna.js"; // Reproduce concurrent eviction's shared directory snapshot while retaining @@ -205,31 +206,29 @@ it("protects a cache request that arrives after an eviction snapshot starts", as releases.push(cache.pin(result.value.key)); return result.value; }; - const second = pinResult(cache.build(await request("second"))); - let warm: ReturnType | undefined; + const pending: ReturnType[] = []; onTestFinished(async () => { snapshot.release(); touch.release(); - await Promise.allSettled(warm === undefined ? [second] : [second, warm]); + await Promise.allSettled(pending); for (const release of releases) release(); const closed = await cache.close(); if (!closed.ok) throw closed.error; }); - await Promise.race([ + const second = pinResult(cache.build(await request("second"))); + pending.push(second); + await awaitAcknowledgement( snapshotStarted.promise, - second.then(() => { - throw new Error( - "Export completed without reaching the eviction snapshot", - ); - }), - ]); - warm = pinResult(cache.build(firstInput)); - await Promise.race([ + second, + "Kuna eviction snapshot", + ); + const warm = pinResult(cache.build(firstInput)); + pending.push(warm); + await awaitAcknowledgement( touchStarted.promise, - warm.then(() => { - throw new Error("Cache request completed without touching its entry"); - }), - ]); + warm, + "Kuna retained-entry touch", + ); listing.names = await actual.readdir(listing.directory); snapshot.release(); await second;