Skip to content

Commit

Permalink
fix: disable parallel on WSL due bugs (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi committed May 14, 2019
1 parent 449e0fc commit d9533dd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
19 changes: 12 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -37,6 +37,7 @@
"dependencies": {
"cacache": "^11.3.2",
"find-cache-dir": "^2.0.0",
"is-wsl": "^1.1.0",
"schema-utils": "^1.0.0",
"serialize-javascript": "^1.7.0",
"source-map": "^0.6.1",
Expand Down
12 changes: 8 additions & 4 deletions src/TaskRunner.js
Expand Up @@ -4,6 +4,7 @@ import cacache from 'cacache';
import findCacheDir from 'find-cache-dir';
import workerFarm from 'worker-farm';
import serialize from 'serialize-javascript';
import isWsl from 'is-wsl';

import minify from './minify';

Expand All @@ -19,10 +20,13 @@ export default class TaskRunner {
// In some cases cpus() returns undefined
// https://github.com/nodejs/node/issues/19022
const cpus = os.cpus() || { length: 1 };
this.maxConcurrentWorkers =
parallel === true
? cpus.length - 1
: Math.min(Number(parallel) || 0, cpus.length - 1);
// WSL sometimes freezes, error seems to be on the WSL side
// https://github.com/webpack-contrib/terser-webpack-plugin/issues/21
this.maxConcurrentWorkers = isWsl
? 1
: parallel === true
? cpus.length - 1
: Math.min(Number(parallel) || 0, cpus.length - 1);
}

run(tasks, callback) {
Expand Down

0 comments on commit d9533dd

Please sign in to comment.