diff --git a/packages/mako/src/runLoaders/parallelLoader.ts b/packages/mako/src/runLoaders/parallelLoader.ts index 64ba286ec..48e9b4e94 100644 --- a/packages/mako/src/runLoaders/parallelLoader.ts +++ b/packages/mako/src/runLoaders/parallelLoader.ts @@ -1,3 +1,4 @@ +import os from 'os'; import { RunLoaderResult } from 'loader-runner'; import { Piscina } from 'piscina'; import { RunLoadersOptions } from '.'; @@ -16,5 +17,8 @@ export function createParallelLoader(renderPath: string) { idleTimeout: 30000, recordTiming: false, useAtomics: false, + maxThreads: + // when cpus is less than "4", the worker pool may lead to panic on linux + os.platform() === 'linux' ? Math.max(os.cpus().length - 3, 1) : undefined, }); }