-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Webpack build hangs with parallel: true #21
Comments
@Pajn Thanks for issue, we have some problem on WSL for |
To set up WSL you need Windows 10, then you should be able to follow this guide https://docs.microsoft.com/en-us/windows/wsl/install-win10 After that you can basically treat is as a normal Ubuntu Linux so install node by following this https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions The only consideration with a case like this is that Linux files are not visible to Windows, so to be able to open files in a graphical editor you need to save them under |
@Pajn oh, i don't have |
You are right that worker-farm is somehow related.
Changing that condition so that I tried running the basic example from the worker-farm readme and that worked without hanging so I guess there some problem with file locking. I'll continue the debugging tomorrow. |
@Pajn thanks for helping! How many cpu you are have? Based on output |
I have four, however the above pstree output is from a run where I limited the number of workers to two, just to see if it did help. I modified the code so that it would still use |
@Pajn Feel free to publish outputs |
Guys i try to reproducible problem but i can't, maybe can create really minimum reproducible test repo with really minimum setup? |
@evilebottnawi you should be able to recreate this by compiling the an Angular demo app (any should do) with I get this issue where the TerserPlugin seems to hang with a lot of node processes showing in Task Manager using 0% CPU resource. |
@charsleysa can you provide instruction for minimum reproducible test repo? |
@evilebottnawi it seems to be something to do with having a project sufficiently large enough producing source maps on a production build. The following instructions assume you have already setup WSL with Node 10.x (node inside WSL) using standard setup instructions. The below instructions are executed inside bash.
|
@charsleysa thanks for instructions, anyway feel free to investigate problem(s), i think problem inside |
WSL is becoming more and more popular. I'm seeing the same problem as well and can confirm that |
@andreialecu can you investigate why it is happens? Don't have WSL around and don't have windows machine near, maybe you can find problem |
I've been digging at it and from my initial findings it seems like this callback is never ran: https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/TaskRunner.js#L74 However, the task itself and the code in |
@andreialecu yep, problem in |
What is |
But like I said, |
Further progress on debugging this, it seems like the forked process' https://github.com/rvagg/node-worker-farm/blob/master/lib/farm.js#L145 However, when running What could be different? |
@andreialecu only setup this options https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/TaskRunner.js#L34 (as i written above) |
I think I found the root cause. It is related to the length of the result being passed from the worker process back to the farm via Making this callback with a shorter string results in all callbacks working: I'm trying to reproduce it here https://github.com/rvagg/node-worker-farm/blob/master/examples/basic/index.js by changing the code to send a 10MB result and it works perfectly: module.exports = function (inp, callback) {
const msg = 'a'.repeat(10 * 1000 * 1000);
callback(null, inp + ' BAR (' + process.pid + ')' + msg)
} So I'm not sure what is going on. |
@Pajn Maybe some characters break this 😕 |
@evilebottnawi Well, I just tested that by dumping the objects returned by the I'm stumped. Perhaps someone can take over. Running out of time assigned to this right now. FWIW: as a quick test, I tried calling back with the first 100000 characters of |
weird 😕 |
A possible workaround for this would be to save all minified scripts to temp files from the worker and call back with the path to the temp files, then load them back in the master. This would probably fix it. How would you feel about this? |
@andreialecu as workaround sounds good, but will be great find real problem why it is doesn't work as expected, maybe bug in |
When this works through a workaround, is the temp directory in /tmp or is it under /mnt/c/ ? I'm wondering if this is a file system related bug. |
@andreialecu reproduce problem ⭐ WIP on fix |
I am on 1803. Surprisingly it worked now for my repo now on WSL😃.Previously it wasn't working, had to manually disable parallel Edit: let me try the repro test Very interesting because it is working on my local repo that once had this problem, but still not working on the reproducible repo. Could it be a dependency problem ? |
Repo #21 (comment) is very hard 😞 i was spent around hour to search configuration and no luck, in future all big repositories will be ignored, it is hard to debug and it spends a lot of time |
I think #21 (comment) webpack config is defined/ constructed dynamically on |
@endiliey @andreialecu looks it is not freeze, try to wait 5-25 minutes (depends on you hardware), problem what source map generation takes a lot of time |
In webpack@5 we update https://github.com/mozilla/source-map to latest version (WASM) and it should solve problem with perf, but here we can't do this 😞 |
Tried on many repos and all works fine, in some repos i have waited around 20 minutes due it is really big application. Just ensure it is not problem in plugin with WSL, just disable source map and try again |
Did you see 0% cpu for node processes for a very long time while you waited, and it eventually finished? Did you try with A problem still exists on WSL that is not present for native Windows or native Linux builds. If you go through my comments above you can use a debugger to attach and break on something inside the terser plugin code even if it is running via Anyway, it's probably not worth working too much on this because I assume that it will automagically fix itself on WSL 2.0, and in the mean time |
I have been running it for 2 hours but it still stucks in 92%. Also 0% node process |
@endiliey @andreialecu it is very strange, 20 min for #21 (comment) and all were minified, maybe you can create other minimum reproducible test repo? |
I am on SSD, maybe WSL has timeouts and in some cases it is failed 😕 |
I can disable parallels on WSL by default, but i want to ensure it is real problem in WSL, not in webpack or other ecosystem |
Okey, we disable parallels on WSL and for 2.0 we migrate on |
Somebody can test master version on WSL? |
Can't setup azure pipelines for WSL, if anyone had experience please put here 😄 |
/cc @Pajn can you test terser-webpack-plugin@2 on WSL? Thanks |
I'm sorry. I gave up on trying to use Windows for development because problems like this was the norm and not an exception so now I only have Linux to test on. |
/cc @andreialecu friendly ping, you are still on WSL? |
I am closing issue, if somebody will get an error, just open a new problem with a minimal example, thanks |
I spent like an hour trying to figure out why Terser refused to run in parallel no matter what I did only to realize that parallel is disabled if you are on WSL. I'm currently on Windows build 19041 (Slow ring insider preview) using WSL2 and it works perfectly with all cores. |
Upgraded my terser plugin from 1.3.5 to 2.3.5 and the issue is resolved, can use parallel now. |
Expected Behavior
That the webpack build completes
Actual Behavior
The webpack build hangs forever (or at least 30 minutes which is the longest I have lasted) after outputting
However changing
parallel: true
toparallel: false
in terser options will cause the build to complete in normal time (around 40s)Code
Full webpack config: https://github.com/Pajn/tscomp/blob/cra2/config/webpack.config.prod.js
How Do We Reproduce?
I suspect this can be related to WSL. If you have some debugging tips I can probably run them.
For the exact same state as I have:
git checkout terser-bug
cd RAXA/packages/web
yarn
yarn add --dev path/to/cloned/tscomp/repo
yarn build
, or for more informationNODE_ENV=production webpack --config node_modules/tscomp/config/webpack.config.prod.js --verbose --info-verbosity verbose --display verbose --profile
The text was updated successfully, but these errors were encountered: