Skip to content

Commit b27e002

Browse files
authored
perf: avoid fetchModule roundtrip if the module is cached (#9075)
1 parent 6b9a1b5 commit b27e002

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/vitest/src/runtime/moduleRunner/startModuleRunner.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ export function startVitestModuleRunner(options: ContextModuleRunnerOptions): Vi
128128
return { externalize: toBuiltin(rawId), type: 'builtin' }
129129
}
130130

131+
// if module is invalidated, the worker will be recreated,
132+
// so cached is always true in a single worker
133+
if (options?.cached) {
134+
return { cache: true }
135+
}
136+
131137
const otelCarrier = traces?.getContextCarrier()
132138
const result = await rpc().fetch(
133139
id,

0 commit comments

Comments
 (0)