From 7d1f86b8f86516a847e837cba10a36ca45a82122 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Thu, 3 Aug 2023 12:10:30 +0200 Subject: [PATCH] fix: don't crash if total memory is not supported (#3879) --- packages/vitest/src/node/config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vitest/src/node/config.ts b/packages/vitest/src/node/config.ts index 7fd5f78069fa..2e317bd48b44 100644 --- a/packages/vitest/src/node/config.ts +++ b/packages/vitest/src/node/config.ts @@ -213,9 +213,11 @@ export function resolveConfig( snapshotEnvironment: null as any, } + const memory = totalmem() + resolved.experimentalVmWorkerMemoryLimit = stringToBytes( getWorkerMemoryLimit(resolved), - resolved.watch ? totalmem() / 2 : totalmem(), + typeof memory === 'number' && resolved.watch ? memory / 2 : memory, ) if (options.resolveSnapshotPath)