diff --git a/packages/vitest/src/node/pools/vm-threads.ts b/packages/vitest/src/node/pools/vm-threads.ts index b48fc60ad957..632ef29352cb 100644 --- a/packages/vitest/src/node/pools/vm-threads.ts +++ b/packages/vitest/src/node/pools/vm-threads.ts @@ -170,9 +170,10 @@ function getMemoryLimit(config: ResolvedConfig) { ) } - if (limit && limit > 1) + // If totalmem is not supported we cannot resolve percentage based values like 0.5, "50%" + if ((typeof limit === 'number' && limit > 1) || (typeof limit === 'string' && limit.at(-1) !== '%')) return stringToBytes(limit) - // just ignore "experimentalVmWorkerMemoryLimit" value because we cannot detect memory limit + // just ignore "memoryLimit" value because we cannot detect memory limit return null } diff --git a/packages/vitest/src/utils/memory-limit.ts b/packages/vitest/src/utils/memory-limit.ts index 535471a254ab..7a4e40b3a737 100644 --- a/packages/vitest/src/utils/memory-limit.ts +++ b/packages/vitest/src/utils/memory-limit.ts @@ -23,7 +23,7 @@ export function getWorkerMemoryLimit(config: ResolvedConfig) { const memoryLimit = config.poolOptions?.vmThreads?.memoryLimit if (memoryLimit) - return stringToBytes(memoryLimit) + return memoryLimit return 1 / (config.poolOptions?.vmThreads?.maxThreads ?? getDefaultThreadsCount(config)) } @@ -94,7 +94,7 @@ export function stringToBytes( return Math.floor(input) } else { - throw new Error('Unexpected numerical input for "experimentalVmWorkerMemoryLimit"') + throw new Error('Unexpected numerical input for "memoryLimit"') } }