@@ -73,32 +73,26 @@ export function startVitestModuleRunner(options: ContextModuleRunnerOptions): Vi
7373 }
7474 : undefined
7575
76- // A fresh worker pays one strictly sequential `fetch` round-trip per module
77- // in its test files' import graphs, even when the server processed all of
78- // them already. Ask the server ONCE per run request for everything it has on
79- // disk and answer those fetches locally. A file change invalidates the module
80- // server-side, dropping it from the snapshot of every subsequent run request,
81- // which keeps reused (isolate: false) workers in sync; an edit DURING a run
82- // was racy before this fast path existed and stays racy with it — the
83- // scheduled rerun always sees the fresh transform.
76+ // A fresh worker pays one sequential `fetch` round-trip per module in its
77+ // test files' import graphs, even when the server has already processed
78+ // them. So the module runner asks the server once for everything it has on
79+ // disk for its first run request, and answers those fetches locally. Modules
80+ // that only later files import are fetched one by one. Keeping the snapshot
81+ // for the runner's lifetime is safe because a worker doesn't outlive a run,
82+ // and the scheduled rerun picks up a file edited during a run.
8483 let warmModules :
8584 | Promise < Record < string , FetchResult | FetchCachedFileSystemResult > | null >
8685 | undefined
87- let warmModulesContext : unknown
8886
8987 function fetchWarmModules ( ) {
90- const workerState = state ( )
91- if ( warmModulesContext !== workerState . ctx ) {
92- warmModulesContext = workerState . ctx
93- warmModules = rpc ( )
94- . fetchWarmModules (
95- environment ( ) ,
96- workerState . ctx . files . map ( ( file ) => file . filepath ) ,
97- )
98- // if the snapshot cannot be fetched, fall back to per-module fetches
99- . catch ( ( ) => null )
100- }
101- return warmModules !
88+ warmModules ??= rpc ( )
89+ . fetchWarmModules (
90+ environment ( ) ,
91+ state ( ) . ctx . files . map ( ( file ) => file . filepath ) ,
92+ )
93+ // if the snapshot cannot be fetched, fall back to per-module fetches
94+ . catch ( ( ) => null )
95+ return warmModules
10296 }
10397
10498 // setup files are re-evaluated before every test file, so a reused worker
0 commit comments