Skip to content

Flaky Windows test: #185 recycled-pid test reads processInfo right after spawn #330

Closed

Description

@TMHSDigital

Summary

The Windows test "recycled server pid (#185) > reaps a record whose server pid now belongs to a newer process" fails intermittently on CI because processInfo() returns null for a child queried the moment it spawns. A red CI run skips the npm publish, so this flake can block a release.

Where

  • src/__tests__/sessions.test.ts:422-445 (the test)
  • src/utils/sessions.ts (processInfo, a PowerShell Get-CimInstance Win32_Process query with a 10 s timeout)

Details

const child = spawn(process.execPath, ["-e", "setTimeout(() => {}, 30000)"], { stdio: "ignore" });
await new Promise((r) => child.once("spawn", r));
const info = processInfo(child.pid!);
expect(info?.image.toLowerCase()).toBe("node.exe"); // fails: info is null

The query runs right after the spawn event, on a loaded runner with coverage on. When PowerShell is slow or the CIM query does not see the new process yet, processInfo returns null and the test fails with expected undefined to be 'node.exe'.

Seen on the build-and-test (windows-latest, 22) and (windows-latest, 24) legs for commits d4225d7 and bdd4697. The same tests passed on neighbouring commits.

Impact

Intermittent red CI on main. Per the release flow, red CI skips the npm publish.

Suggested fix

Poll processInfo(child.pid) for a few seconds until it returns a value before asserting, as the newer pid-reuse test does by waiting briefly after spawn. Optionally raise the test timeout to cover a slow PowerShell start.

Acceptance criteria

  • The test waits until the process details are readable before asserting
  • The Windows legs pass repeatedly without this failure

Getting started

  • Relevant files: src/__tests__/sessions.test.ts, src/utils/sessions.ts
  • How to run tests: npm run build && npm test (also npm run typecheck and npm run lint)
  • Related docs: CONTRIBUTING.md, AGENTS.md

Related: #185


Filed by repo-audit/fix-issues at abbab4e. Severity: medium. Effort: S. audit-key: testing|src/__tests__/sessions.test.ts|recycled-server-pid-processInfo-null

Activity

  1. added
    good first issue
    testing
    on Nov 10, 2026
  2. TMHSDigital commented on Nov 10, 2026

    @TMHSDigital
    OwnerAuthor

    Fixed in c4a4d69: the test polls processInfo (up to 10 × 500 ms) until the child's details are readable, and its timeout is now 120 s. Passes locally; the Windows CI legs will show whether it holds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cigood first issuepriority: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions