Fix Windows CI test failures: certificate-manager flakiness and native addon segfault - #3740
Merged
Merged
Conversation
Moved setPlatform('linux') from each individual test into a beforeEach
for the trustRootCA describe block, and suppressed expected console.error
output with a spy. This prevents the platform from being in an
indeterminate state if a prior test's afterEach restore races with the
next test's async mock setup, which was the likely cause of intermittent
failures on the 'rejects when sudo.exec reports an error' test in CI.
…pi-tui native addon
Collaborator
📊 Performance Test ResultsComparing 4a111eb vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
1 task
…void IPC handler path
…void IPC handler path
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
Claude Code investigated the CI failure logs, identified root causes, and implemented the fixes, after thorough debugging and trying multiple different approaches.
Proposed Changes
This PR fixes two distinct Windows CI issues:
1. Flaky
certificate-managertestThe
rejects when sudo.exec reports an errortest was intermittently failing on Windows CI. Each test calledsetPlatform('linux')individually, leaving a window where the prior test'safterEach(restoring the platform towin32) could race with the next test's async mock setup. Fixed by movingsetPlatform('linux')into abeforeEachfor thetrustRootCAdescribe block so the platform is guaranteed to be set before any async code runs.2. Node.js segfault on Windows CI
After the
@mariozechner/pi-*→@earendil-works/pi-*0.78.0 migration (#3707), the new packages bundle native.nodeaddons (clipboard-win32,win32-console-mode). When Vitest runs tests in its defaultthreadspool, these native addons are loaded into worker threads and don't clean up properly on thread exit, causing a segfault that kills the entire test process.Fixed by switching the CLI project's Vitest pool from
threadstoforks(apps/cli/vitest.config.ts). Each test file now runs in an isolated child process, so a native addon crash cannot propagate across files.The pool change also surfaced two pre-existing test issues in
export.test.tsandimport.test.ts: withpool:forks, each test file runs as a child process which hasprocess.senddefined. Both commands useif (process.send)to choose between an IPC event handler and a logger event handler — the tests expect the logger path but were silently taking the IPC path. Fixed by stubbingprocess.sendtoundefinedinbeforeEachand restoring viavi.unstubAllGlobals()inafterEach.Testing Instructions
npm test -- apps/cli/lib/tests/certificate-manager.test.ts— all 10 tests passnpm test -- apps/cli/commands/tests/export.test.ts apps/cli/commands/tests/import.test.ts— all 12 tests passPre-merge Checklist