Repository navigation
Tests: build dist/ once; Vitest: wait for bench workers to exit before reading their logs - #8
Merged
Merged
Conversation
bench.spec.ts and preset.e2e.spec.ts each ran `vp pack` in a beforeAll, and `vp pack` empties dist/ first. With test files in parallel, one rebuild deleted chunks that the other file's child process was loading. After #7 added a third rebuild, main and the version PR failed three ways on three runners: ERR_MODULE_NOT_FOUND on dist/parseLog-*.mjs (Ubuntu), "Cannot find package 'deoptkit/bench'" (macOS), and a findings.json without the expected finding, because the teardown could not analyze its log (Windows). A Vitest global setup now builds dist/ once, before any file runs, and no spec rebuilds it.
|
The changes in this PR will be included in the next version bump.
|
…d finding This test has failed on one Windows lane in three of the last five runs, while the test before it finds the same finding in the same logs. The failure now reports how many findings and logs findings.json holds, how many logs the manifest lists, and the child's stderr, where the teardown reports a log it could not analyze.
Vitest starts stopping a worker when its test file ends, but waits for the exit only when it closes the pool, after global teardowns ("Runner terminations are started but not awaited until the end of full run"). V8 writes the end of a log as the process exits: about 7% of one measured log arrived only at exit. So the teardown could read a log before its worker finished it, and write a findings.json without findings that were in the log. That is the Windows-only failure of "the teardown writes findings.json that the LSP can publish", where the test before it read the same logs later and found the finding.
The teardown now waits for each of this run's logs to lose its writer (the pid in v8-<pid>.log) before it reads them, for up to 10 s, and says on stderr which worker was still running if any was. With isolate: false Vitest keeps workers alive until after the teardown, so the wait can only time out there.
… logs may be unfinished With isolate: false Vitest stops its workers only when it closes the pool, after the teardown, so waiting for them added the whole 10 s timeout to every run and still read unfinished logs. The setup reads isolate from the project; the teardown then skips the wait and says on stderr why findings.json may miss findings, and what to do instead.
…for each log's writer On Linux, pids 1 and 2 always belong to running processes, so v8-1.log and v8-2.log made the teardown wait its full 10 s for system processes and the test timed out on every Ubuntu lane.
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.


Fixes the CI failures on
mainand the version PR (#5) after #7.bench.spec.tsandpreset.e2e.spec.tseach ranvp packin abeforeAll, andvp packemptiesdist/first (clean: true). With test files in parallel, one rebuild deleted chunks that the other file's child process was loading. The race was already there with two rebuilds; #7 added a third, and it then failed on two runners:ERR_MODULE_NOT_FOUNDondist/parseLog-*.mjsinbench.spec.ts.Cannot find package 'deoptkit/bench'in the iteration-limit project.And a Windows-only failure, in the product. On one Windows lane per run,
findings.jsonlacked thegetXfinding while the test before it found that finding in the same logs. That was not the race: it failed again here withdist/built once. The cause is the order Vitest closes in. It starts stopping a worker when its file ends, but waits for the exit only inpool.close(), after global teardowns ("Runner terminations are started but not awaited until the end of full run"). V8 writes the end of a log as the process exits: sampling one log's size while its process ran, about 7% arrived only at exit. So the teardown could read a log before its worker finished it. The test after it reads once Vitest has exited, and sees the whole log.The teardown now waits for each of this run's logs to lose its writer (the pid in
v8-<pid>.log), up to 10 s, and names any worker still running on stderr. Withisolate: falseVitest keeps workers until after the teardown, so there it skips the wait and says on stderr that the logs are unfinished. This affects users' ownfindings.jsontoo, so the bump file is a patch.A Vitest global setup (
src/__tests__/buildDist.ts) now buildsdist/once, before any test file runs. Vitest finishes every project's global setup before it collects a file, so nothing can emptydist/while a test is using it. No spec callsensureDist()any more.Checked:
dist/(grep forensureDistand"pack"in specs finds none).dist/deleted,bench.spec.tsalone passes, because the setup builds it. With the setup removed too, it fails.isolate: false(it returns at once and says why). Mutations: no wait, every writer treated as gone, the pid read wrongly,isolate: falseignored, no message, never waiting.vp checkis clean, andvp run testpasses 194 tests in 26 files on Node 26.13 (Windows).