Repository navigation
test(windows): stop the NSIS capability probe failing on a slow PowerShell cold start - #23381
Conversation
…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.
|
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 configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe 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 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Raised the probe watchdog to 60s — the literal
timeoutMs: 20_000inrunProbebecame a sharedPROBE_TIMEOUT_MS = 60_000. On a contendedpackage (windows)runner the first (SysWOW64) PowerShell cold start could exceed 20s, so the child was SIGTERMed and graded ascode: nullrather than a working probe. - Added a per-test timeout — both
it.eachblocks now pass{ timeout: PROBE_TEST_TIMEOUT_MS }(75s), becauserunProcessSyncblocks the event loop and vitest's configured 30stestTimeoutwould 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.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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.mjshas a Windows-only block,NSIS capability probe under Restricted policy, that launches the realpowershell.exe(both 64-bitSystem32and 32-bitSysWOW64) and proves theWindows installer's inline
Get-CimInstanceprocess query still runs when theexecution policy is
Restricted. It asserts the probe succeeds — exit code 0and 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 isSIGTERMed, and the assertion sees
code: nullinstead of0: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
runProcessSyncblocks the event loop and vitest's 30-secondtestTimeoutdefault 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
Restrictedstill 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 wasempty — 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.mjssetsDEFAULT_SYNC_TIMEOUT_MS = 60_000with the same stated rationale — cap the callso a wedged PowerShell cannot block the harness until the whole job times out —
and
config/reliability-gates.jsonccites that "60-second cap on everysynchronous 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.
PowerShell probes; they cap generously. A retry would also hide a real
regression behind a second chance.
src/main/pwsh.ts) does warm its pwshavailability 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.
todo, or narrow the platform guard. Rejected — that removes thecoverage 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 intoPROBE_TIMEOUT_MSmoves theSystem32success case and both injected-failure cases with it. The SysWOW64success 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 probeCI 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 isstill 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 throwingduring collection.
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 1changed 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.exespawns, 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 gatereferences this test file, so none needed updating.
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
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
probe executes — only how long the test waits for it.
untouched, so it still runs on Windows CI and stays skipped elsewhere.
probe.
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)