-
-
Notifications
You must be signed in to change notification settings - Fork 590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(terser): always make at least 1 worker thread #1604
base: master
Are you sure you want to change the base?
Conversation
A future enhancement could be to use os.availableParallelism (requires v18.14+), since it's recommended over using |
Looks like you need an upstream update:
That should get you set so that Windows Node 20 action passes. |
Alright I updated your fork for you from upstream/master and looks like there's a failure on Windows directly related to WASM. Please have a look. |
packages/terser/test/test.js
Outdated
@@ -356,3 +358,21 @@ test.serial('terser preserve vars in nameCache when provided', async (t) => { | |||
} | |||
}); | |||
}); | |||
|
|||
test.serial('minify when os.cpus().length === 0', async (t) => { | |||
const original = os.cpus; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the test needs to also make os.availableParallelism
unavailable, otherwise it won't use os.cpus
.
Aren't V8 errors either bugs in node itself or OOMs usually? |
Not sure in this case. It doesn't happen on the Ubuntu builds. The existing code doesn't throw this error, so it's possible the changes have surfaced a bug. |
c544fde
to
a929458
Compare
|
||
test.serial('minify when os.cpus().length === 0', async (t) => { | ||
const original = os.cpus; | ||
os.cpus = () => []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe overwriting os.cpus
in this way is breaking Node 20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@easrng could you please take a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@easrng should this also include os.availableParallelism = null;
?
a69c299
to
a9b9cd3
Compare
Maybe this change is worth a try? diff --git a/packages/terser/test/test.js b/packages/terser/test/test.js
index 9dabacd..fd36d58 100644
--- a/packages/terser/test/test.js
+++ b/packages/terser/test/test.js
@@ -360,7 +360,9 @@ test.serial('terser preserve vars in nameCache when provided', async (t) => {
});
test.serial('minify when os.cpus().length === 0', async (t) => {
- const original = os.cpus;
+ const originalAP = os.availableParallelism;
+ const originalCPUS = os.cpus;
+ os.availableParallelism = null;
os.cpus = () => [];
try {
const bundle = await rollup({
@@ -373,6 +375,7 @@ test.serial('minify when os.cpus().length === 0', async (t) => {
t.is(output.code, '"use strict";window.a=5,window.a<3&&console.log(4);\n');
t.falsy(output.map);
} finally {
- os.cpus = original;
+ os.availableParallelism = originalAP;
+ os.cpus = originalCPUS;
}
}); It passes locally on Node 21.5.0. |
@shellscape I can't tell if the tests ran after @easrng last commit. If not, would it be possible to run them again? |
Rollup Plugin Name:
terser
This PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Resolves #1594
Description
On some platforms (I noticed it on Android),
os.cpus()
can return[]
, resulting in no workers being spawned, so the jobs never run. This patch makes sure the maximum number of workers is never 0.