From 8e6bc83ce65e8f665358f56d1f51d9028dadd88c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 8 Sep 2026 13:52:47 +0200 Subject: [PATCH] Assert descriptor selection instead of reading a live descriptor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test called openProviderHealthIdentity to prove the descriptor is taken despite a foreign LISTEN_PID, which meant it did readFileSync on fd 3 — a live handle inside the vitest worker. On Windows that blocks rather than throwing, so the worker hung and took the whole suite with it: `vitest run` never terminated on this repo, and the cause was read as "vitest is flaky on Windows" for most of a night. The decision under test is which descriptor gets chosen. Reading a real one was never part of it, so this asserts passedDescriptor directly. Co-Authored-By: Claude Opus 5 --- tests/presence-identity-descriptor.test.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/presence-identity-descriptor.test.ts b/tests/presence-identity-descriptor.test.ts index 01300da..97c5233 100644 --- a/tests/presence-identity-descriptor.test.ts +++ b/tests/presence-identity-descriptor.test.ts @@ -10,6 +10,7 @@ import { describe, expect, it } from "vitest"; import { openOrEnrollProviderHealthIdentity, openProviderHealthIdentity, + passedDescriptor, providerHealthPublicIdentity, } from "../src/provider-health-identity.js"; @@ -81,19 +82,25 @@ describe.skipIf(!machineIdAvailable)("presence identity from a passed descriptor describe("presence identity descriptor selection", () => { const dir = os.tmpdir(); - it("takes the named descriptor even when LISTEN_PID is another namespace's pid", async () => { + it("takes the named descriptor even when LISTEN_PID is another namespace's pid", () => { // Idunn launches candidates with PrivatePIDs=yes, so systemd sets // LISTEN_PID to the pid it knows in the outer namespace while this process // sees a namespace-local one. They never match. Refusing the descriptor on // that basis sent Heimdall down the self-enrolling path, where it signed - // health with a key nothing trusts and warmed forever -- so the descriptor - // must still be taken, and the attempt to read it is the proof. - await expect( - openProviderHealthIdentity(path.join(dir, `heimdall-outer-pid-${process.pid}.cc`), { + // health with a key nothing trusts and warmed forever. + // + // This asserts the *selection*, not a read. An earlier version of this test + // called openProviderHealthIdentity, which then did readFileSync on fd 3 -- + // a live handle inside the vitest worker. On Windows that blocks instead of + // throwing, which hung the worker and took the whole suite with it. The + // decision under test is which descriptor gets chosen; reading a real one + // is not part of it. + expect( + passedDescriptor("gamecult-runtime-presence-identity", { LISTEN_FDNAMES: "gamecult-runtime-presence-identity", LISTEN_PID: String(process.pid + 1), }) - ).rejects.toThrow(); + ).toBe(3); }); it("ignores a descriptor set that does not name the presence identity", async () => {