Skip to content

test(windows): stop the NSIS capability probe failing on a slow PowerShell cold start - #23381

Merged
nwparker merged 1 commit into
mainfrom
fix/nsis-process-probe-timeout
Sep 27, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/nsis-process-probe-timeout

Conversation

@nwparker

@nwparker nwparker commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​15
Prod 0 0 0 0

ELI5

A Windows-only test was being marked as failed simply because the build machine
was busy. The test starts up Windows PowerShell and waits up to 20 seconds for an
answer; on a loaded machine PowerShell sometimes needs longer than that just to
start. We now wait up to 60 seconds. Nothing about the product changes — this is
purely CI reliability.

What Changed

config/scripts/nsis-process-check.test.mjs has a Windows-only block,
NSIS capability probe under Restricted policy, that launches the real
powershell.exe (both 64-bit System32 and 32-bit SysWOW64) and proves the
Windows installer's inline Get-CimInstance process query still runs when the
execution policy is Restricted. It asserts the probe succeeds — exit code 0
and a receipt on stdout — not that it succeeds quickly.

Before: every probe was capped at 20 seconds. On a contended
package (windows) runner the 32-bit spawn reaches that cap, the child is
SIGTERMed, and the assertion sees code: null instead of 0:

AssertionError: {"code":null,"signal":"SIGTERM","stdout":"","stderr":"","outputTruncated":false,"timedOut":true}: expected null to be +0

Durations were 20025–20109 ms against the 20000 ms cap — the child never
answered, it was killed at the ceiling. A working probe was graded as a refused
one.

After: the cap is 60 seconds, held in one constant that all four probes
share. Both parametrised blocks also get an explicit per-test timeout, because
runProcessSync blocks the event loop and vitest's 30-second testTimeout
default would otherwise become the real ceiling and the raised cap would never
take effect.

No assertion changed. A query that is genuinely broken or refused under
Restricted still fails the test — it just takes longer to say so.

Why

The flake appeared on eight unrelated branches in one session and passed on
rerun every single time. The signature above was confirmed on five of them.
The hang point moved between runs — on one occurrence stdout already contained
the policy receipt (orca-nsis: restricted policy verified), on another it was
empty — so the delay is host contention, not a deterministic break in the query.

Why 60 seconds and not a guess. It is the ceiling this repository already
applies to synchronous PowerShell probes:
tests/tools/win-update-e2e/powershell-runner.mjs sets
DEFAULT_SYNC_TIMEOUT_MS = 60_000 with the same stated rationale — cap the call
so a wedged PowerShell cannot block the harness until the whole job times out —
and config/reliability-gates.jsonc cites that "60-second cap on every
synchronous PowerShell probe" as part of a Windows gate's performance budget. The
timeout here is a watchdog, not a latency budget, so it should match that
established ceiling rather than sit at a third of it.

Alternatives considered.

  • Leave 20s and retry on timeout. Neighbouring Windows tests do not retry real
    PowerShell probes; they cap generously. A retry would also hide a real
    regression behind a second chance.
  • Add a warm-up spawn. Production code (src/main/pwsh.ts) does warm its pwsh
    availability cache, but no neighbouring Windows test uses that idiom, and it
    adds spawns and a failure-swallowing hook for an effect the raised cap already
    covers.
  • Skip, todo, or narrow the platform guard. Rejected — that removes the
    coverage rather than stabilising it.

All four probes, not just the observed one. The cap was a single literal
inside the shared runProbe, so lifting it into PROBE_TIMEOUT_MS moves the
System32 success case and both injected-failure cases with it. The SysWOW64
success case is the only one seen failing because it is the file's first spawn
and therefore pays WoW64 and WMI cold start; the others are one slow scheduling
slice away from the same fate.

Prior mitigation. The cap has never been adjusted since it was introduced in
#22872. The previous attempt at this flake was scheduling, not budget: #23376
split the file into its own Test Windows installer process probe CI step to
"keep cold CIM startup out of the concurrent Electron/native process workload",
enforced by client-hosted-browser-package-coverage.test.mjs. That isolation is
still in place and unchanged here; it reduced the contention but did not remove
it.

Linked Issue

Fixes #

Visual Proof

N/A — test-only change to a timeout constant. There is no UI or user-visible
behaviour involved.

Testing

The failing test is Windows-only (describe.runIf(process.platform === 'win32'))
and this was developed on macOS, so the four probes could not be executed
locally. Being explicit about the split:

Verified locally (macOS):

  • vitest run --config config/vitest.config.ts config/scripts/nsis-process-check.test.mjs —
    6 passed, 4 skipped. The two platform-independent assertions pass, and the four
    Windows probes are collected and reported as skipped, which confirms the
    it.each(name, options, fn) form registers them correctly rather than throwing
    during collection.
  • The contract tests that reference this file all pass:
    client-hosted-browser-package-coverage.test.mjs (CI step ordering),
    pr-code-change-scope.test.mjs, script-module-dependencies.test.mjs,
    check-reliability-gates.test.mjs — 79 passed, 4 skipped.
  • node config/scripts/check-changed-code-quality.mjs — 0 new findings across 1
    changed file (all seven sub-gates).
  • oxlint (1.85.0, the declared version) — clean.
  • oxfmt --check (0.70.0, the declared version) — correctly formatted.

Could not verify locally: the actual 32-bit and 64-bit powershell.exe
spawns, and therefore the real duration of a warm probe under the new cap. Those
run for the first time in this PR's package (windows) job. No reliability gate
references this test file, so none needed updating.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

This changes an existing test's watchdog only; there is no new behaviour to cover
with a new test.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Security: none. No production code, no new command, no change to what the
    probe executes — only how long the test waits for it.
  • Cross-platform: the block is already Windows-only and its platform guard is
    untouched, so it still runs on Windows CI and stays skipped elsewhere.
  • Remote SSH / Mobile: not applicable; this is a local Windows installer
    probe.
  • Backwards compatibility: no wire, config, or API surface touched.
  • Performance: worst case for the CI step grows only when a probe is already
    failing. A healthy probe finishes in the same time it does today; a wedged one
    now takes up to 60s instead of 20s before failing, which is the trade for not
    mis-grading a slow-but-working probe. The step remains isolated from the
    concurrent native test workload.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…Shell cold start

`NSIS capability probe under Restricted policy` spawns real Windows PowerShell
5.1 to prove the installer's inline `Get-CimInstance` query survives a Restricted
execution policy. The probe was capped at 20s, and on a contended
`package (windows)` runner the 32-bit (SysWOW64) spawn reaches that cap: the child
is SIGTERMed and the suite reports `code: null` against `toBe(0)`, so a healthy
probe is graded as a refused one. It appeared on eight unrelated branches in one
session and passed on rerun every time; the point of the hang varied run to run
(on one occurrence stdout already held the policy receipt, on another it was
empty), which is a slow host rather than a broken query.

Raise the cap to 60s, the ceiling the harness in
`tests/tools/win-update-e2e/powershell-runner.mjs` already applies to every
synchronous PowerShell probe for the same reason - stop a wedged call eating the
job, not time a healthy one. The cap lives in one constant that all four probes
share, so the System32 pair and both injected-failure cases move with it; the
SysWOW64 success case is only the one observed failing because it is the file's
first spawn and pays WoW64 and WMI cold start.

Give both parametrised blocks an explicit per-test timeout as well. `runProcessSync`
blocks, so vitest's 30s `testTimeout` default would otherwise become the real
ceiling and the raised cap would never apply.

No assertion changes. A genuinely refused or wedged query still fails, now on
evidence rather than on the runner's mood; it just takes longer to say so.
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 903e7c50-1a93-4f8a-ae9b-29b82599b4d0

📥 Commits

Reviewing files that changed from the base of the PR and between 0697014 and afbd256.

📒 Files selected for processing (1)
  • config/scripts/nsis-process-check.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The Windows Restricted-policy capability-probe tests now use a 60-second synchronous probe timeout and a 75-second Vitest timeout. The SysWOW64 and System32 success and injected-query-failure tests retain their existing assertions.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to afbd2

The change gives the Windows probes more time while retaining a bounded timeout and unchanged assertions. No actionable merge-blocking risk is indicated.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Windows NSIS capability probe and the slow PowerShell startup timeout issue.
Description check ✅ Passed The description is complete and focused. It explains the problem, the timeout and test-timeout changes, rationale, alternatives, testing limits, and compatibility impact. The empty issue reference is …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Raised the probe watchdog to 60s — the literal timeoutMs: 20_000 in runProbe became a shared PROBE_TIMEOUT_MS = 60_000. On a contended package (windows) runner the first (SysWOW64) PowerShell cold start could exceed 20s, so the child was SIGTERMed and graded as code: null rather than a working probe.
  • Added a per-test timeout — both it.each blocks now pass { timeout: PROBE_TEST_TIMEOUT_MS } (75s), because runProcessSync blocks the event loop and vitest's configured 30s testTimeout would otherwise fail a slow-but-successful probe.
  • No assertion or production change — a genuinely broken/refused query still fails; only the watchdog moved.

I verified the load-bearing claims rather than taking them on faith: config/vitest.config.ts:47 sets testTimeout: 30_000, and @vitest/runner's withTimeout rejects a sync test that outran its timeout via the elapsed check after fn() returns (chunk-artifact.js:2291), so the per-test override is genuinely required — the timer itself cannot interrupt the blocking spawn, but the post-return check still would. The it.each(cases)(name, options, fn) form is supported (tasks.d-DEYaIMIu.d.ts:693), and the cited ceiling in tests/tools/win-update-e2e/powershell-runner.mjs:14 is indeed 60_000. The CI step is isolated (pr.yml:1012) under a 30-minute job, so the worst-case increase (~2 min if both success probes wedge) is safe.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit a4b60c2 into main Sep 27, 2026
34 checks passed
@nwparker
nwparker deleted the fix/nsis-process-probe-timeout branch September 27, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant