Skip to content

Commit

Permalink
fix: check memory and limit value
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 3, 2023
1 parent 7d1f86b commit f8dfbd3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/vitest/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,20 @@ export function resolveConfig(
}

const memory = totalmem()
const limit = getWorkerMemoryLimit(resolved)

resolved.experimentalVmWorkerMemoryLimit = stringToBytes(
getWorkerMemoryLimit(resolved),
typeof memory === 'number' && resolved.watch ? memory / 2 : memory,
)
if (typeof memory === 'number') {
resolved.experimentalVmWorkerMemoryLimit = stringToBytes(
limit,
resolved.watch ? memory / 2 : memory,
)
}
else if (limit > 1) {
resolved.experimentalVmWorkerMemoryLimit = stringToBytes(limit)
}
else {
// just ignore "experimentalVmWorkerMemoryLimit" value because we cannot detect memory limit
}

if (options.resolveSnapshotPath)
delete (resolved as UserConfig).resolveSnapshotPath
Expand Down

0 comments on commit f8dfbd3

Please sign in to comment.