This repository was archived by the owner on Aug 30, 2026. It is now read-only.
fix(vitest): resolve the quarantine runner with the current build's extension - #253
Open
QuanticPotatoes wants to merge 1 commit into
Open
fix(vitest): resolve the quarantine runner with the current build's extension#253QuanticPotatoes wants to merge 1 commit into
QuanticPotatoes wants to merge 1 commit into
Conversation
…xtension _configureRunner hardcoded 'runner.js', but the build emits runner.mjs/runner.cjs only — in the published package the injected path fails native resolution with ERR_MODULE_NOT_FOUND in every worker, aborting the whole suite (0 tests collected) as soon as the quarantine list is non-empty. It only worked in this repo's own tests because vite-node remaps the .js specifier onto src/runner.ts. Resolve the sibling with the same extension as the current module instead: dist/index.cjs -> runner.cjs, dist/index.mjs -> runner.mjs, src (dev) -> runner.ts. Adds a dist-mode regression test that consumes the built package the way a real consumer does — it fails on main and passes with the fix. Fixes Mergifyio#169
Contributor
Merge Protections🔴 2 of 6 protections blocking · waiting on 👀 reviews and 🤖 CI
🔴 ApprovalWaiting for
This rule is failing.
🟠 Continuous IntegrationWaiting for
Waiting checks:
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #169.
Problem
MergifyReporter._configureRunnerinjectsresolve(dir, 'runner.js')as the custom vitest runner, but the build (tsdown,format: ['esm', 'cjs']) only emitsdist/runner.mjsanddist/runner.cjs— there is norunner.jsin the published package. As soon as the quarantine list is non-empty (or flaky detection configures the runner), every worker dies withERR_MODULE_NOT_FOUNDbefore collecting a single test, aborting the entire suite.We were hit by this in production CI on 2026-08-05: the first quarantine entry ever created on our repo flipped the latent path on and took down every vitest tier org-wide (0 tests collected, one collect error per file), on vitest 4.0.18 and 3.2.4 alike — not only 4.x as #169 reports.
0.3.1is equally affected.Why the existing tests didn't catch it
tests/runner.test.tsexercises the quarantine path end-to-end and passes — because it imports from../src/reporter.js, so the injected path issrc/runner.js, and vite-node remaps that.jsspecifier ontosrc/runner.ts. In the published package the injecteddist/runner.jspath goes through native node resolution in the worker, which does no such remapping.Fix
Resolve the runner sibling with the same extension as the currently-executing module:
dist/index.cjs→dist/runner.cjsdist/index.mjs→dist/runner.mjssrc/reporter.ts(dev/tests) →src/runner.tsOne rule, correct in all three contexts, no behavior change in dev.
Regression test
Adds
tests/dist-runner.test.ts: the same quarantine scenario asrunner.test.ts, but importingMergifyReporterfrom../dist/index.mjs— i.e. consuming the built artifact the way a real consumer does. It fails onmain(expected 'failed' to be 'passed') and passes with the fix. (It requirespnpm buildto have run before tests, which the workspace setup already does.)Also verified from a standalone external project consuming the packed tarball: with the fix, the
ERR_MODULE_NOT_FOUNDcrash is gone on vitest 4.0.18 and 4.1.8.Side observation (out of scope here)
While validating from the standalone consumer (vitest 4.0.18 and 4.1.8, CLI runs), failure absorption did not engage even though the runner loaded and
isQuarantinedmatched — whereas it works in this repo's own tests (vitest 4.1.7, programmaticstartVitest). Possibly a separate vitest-version-sensitivity issue worth a look; happy to open a separate issue with the repro if useful.