From b27e002e578e7b6cf182c3c173ac5d8fd390598d Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 21 Nov 2025 17:29:44 +0100 Subject: [PATCH] perf: avoid fetchModule roundtrip if the module is cached (#9075) --- .../vitest/src/runtime/moduleRunner/startModuleRunner.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vitest/src/runtime/moduleRunner/startModuleRunner.ts b/packages/vitest/src/runtime/moduleRunner/startModuleRunner.ts index 0a26fce42..174a9e82f 100644 --- a/packages/vitest/src/runtime/moduleRunner/startModuleRunner.ts +++ b/packages/vitest/src/runtime/moduleRunner/startModuleRunner.ts @@ -128,6 +128,12 @@ export function startVitestModuleRunner(options: ContextModuleRunnerOptions): Vi return { externalize: toBuiltin(rawId), type: 'builtin' } } + // if module is invalidated, the worker will be recreated, + // so cached is always true in a single worker + if (options?.cached) { + return { cache: true } + } + const otelCarrier = traces?.getContextCarrier() const result = await rpc().fetch( id, -- 2.51.2