Giter Club home page Giter Club logo

Comments (71)

boardend avatar boardend commented on June 2, 2024 2

I've just tried to reproduce vuejs/vue-cli#3327 with parallel: true on WSL (1803) again and couldn't get into the lock situation anymore. Looks like the issue was fixed in WSL.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024 2

Okey, we disable parallels on WSL and for 2.0 we migrate on jest-worker (they work with WSL) #89

from terser-webpack-plugin.

randak avatar randak commented on June 2, 2024 1

This thread caught my eye as I was searching for possible reasons we are seeing CI builds occasionally time out (webpack hanging for 45+ minutes). We are not running WSL, but this in particular stood out to me:

if you watch Task Manager you'll notice that eventually the node processes will just cease utilizing CPU resource with the build reporting 92% chunk asset optimization TerserPlugin (as pictured below)

I've seen our build hang for a while running locally on my Mac, and it was always at 92%. I haven't been able to get any more details out of our CI build hangs yet, but I'm going to test the parallel setting and see if it makes any difference.

I should note that this is an intermittent issue for us; I'm not sure if other people are seeing this consistently or not.

from terser-webpack-plugin.

endiliey avatar endiliey commented on June 2, 2024 1

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
Edit 2: Doesn't work on the #21 (comment)

image

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 ?

from terser-webpack-plugin.

Pajn avatar Pajn commented on June 2, 2024 1

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.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@Pajn Thanks for issue, we have some problem on WSL for uglify plugin webpack-contrib/uglifyjs-webpack-plugin#302, seems problem in worker-farm, thanks for reproducible test repo, i am not familiar with WSL, can you provide instruction how i can setup this env?

from terser-webpack-plugin.

Pajn avatar Pajn commented on June 2, 2024

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
Git can be installed via sudo apt install git

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 /mnt/c

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@Pajn oh, i don't have windows 10 right now, can debug this only on next week, feel free to debug problem self. Here default arguments to work-farm https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/TaskRunner.js#L36, maybe we need improve this check process.platform === 'win32' and pass maxConcurrentCallsPerWorker: 1 on WSL

from terser-webpack-plugin.

Pajn avatar Pajn commented on June 2, 2024

You are right that worker-farm is somehow related.
This is what I get from pstree in a stuck build

  β”‚   β”‚   β”œβ”€node /usr/share/yarn/bin/yarn.js build
  β”‚   β”‚   β”‚   β”œβ”€sh -c tscomp build
  β”‚   β”‚   β”‚   β”‚   └─node /c/Users/Rasmus/Development/RAXA/packages/web/node_modules/.bin/tscomp build
  β”‚   β”‚   β”‚   β”‚       β”œβ”€node /c/Users/Rasmus/Development/RAXA/packages/web/node_modules/tscomp/scripts/build.js
  β”‚   β”‚   β”‚   β”‚       β”‚   β”œβ”€node /c/Users/Rasmus/Development/RAXA/packages/web/node_modules/tscomp/node_modules/worker-farm/lib/child/index.js /usr/bin/node /c/Users/Rasmus/Development/RAXA/packages/web/node_modules/tscomp/scripts/build.js
  β”‚   β”‚   β”‚   β”‚       β”‚   β”‚   └─5*[{node}]
  β”‚   β”‚   β”‚   β”‚       β”‚   β”œβ”€node /c/Users/Rasmus/Development/RAXA/packages/web/node_modules/tscomp/node_modules/worker-farm/lib/child/index.js /usr/bin/node /c/Users/Rasmus/Development/RAXA/packages/web/node_modules/tscomp/scripts/build.js
  β”‚   β”‚   β”‚   β”‚       β”‚   β”‚   └─5*[{node}]
  β”‚   β”‚   β”‚   β”‚       β”‚   └─9*[{node}]
  β”‚   β”‚   β”‚   β”‚       └─5*[{node}]
  β”‚   β”‚   β”‚   └─9*[{node}]

Changing that condition so that maxConcurrentCallsPerWorker: 1 is passed (process.platform is linux) did not help unfortunately.

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.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@Pajn thanks for helping! How many cpu you are have? Based on output worker-farm is create child processes but don't get response.

from terser-webpack-plugin.

Pajn avatar Pajn commented on June 2, 2024

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 worker-farm with only one worker, and then it did finish again. I also tried to attach strace to see if I got some hint of the problem but did not find anything useful in the output. If you are interested I can of course share those outputs.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@Pajn Feel free to publish outputs

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Guys i try to reproducible problem but i can't, maybe can create really minimum reproducible test repo with really minimum setup?

from terser-webpack-plugin.

charsleysa avatar charsleysa commented on June 2, 2024

@evilebottnawi you should be able to recreate this by compiling the an Angular demo app (any should do) with aot and optimization flags turned on.

I get this issue where the TerserPlugin seems to hang with a lot of node processes showing in Task Manager using 0% CPU resource.

image

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@charsleysa can you provide instruction for minimum reproducible test repo?

from terser-webpack-plugin.

charsleysa avatar charsleysa commented on June 2, 2024

@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.

  1. clone this repo https://github.com/formio/angular-demo
  2. cd into the cloned repo directory
  3. install the angular cli npm install -g @angular/cli
  4. install the repo requirements npm install
  5. run a standard build just to check that everything is working ng build
  6. run a production build with source maps turned on ng build --configuration=production --project=demo --source-map=true
  7. if you watch Task Manager you'll notice that eventually the node processes will just cease utilizing CPU resource with the build reporting 92% chunk asset optimization TerserPlugin (as pictured below)

image

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@charsleysa thanks for instructions, anyway feel free to investigate problem(s), i think problem inside worker-farm, maybe you can find problem faster than i can, because i need time to setup WSL

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

WSL is becoming more and more popular. I'm seeing the same problem as well and can confirm that parallel: false works. If #6 is applied to make parallel the default, then this needs to be fixed first.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@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

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

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 minify.js is called, and is returning properly. I'm trying to investigate why it never gets there now. I suspected it would be a problem in worker-farm but the examples in the worker-farm repo and all of its tests pass properly.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu yep, problem in worker-farm, maybe we need to setup more options (https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/TaskRunner.js#L34) for WSL

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

What is process.platform on WSL?

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

But like I said, worker-farm's entire test suite passes properly.

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

Further progress on debugging this, it seems like the forked process' on('message') handler in worker-farm is never called when running with this plugin on WSL:

https://github.com/rvagg/node-worker-farm/blob/master/lib/farm.js#L145

However, when running worker-farm outside of this scenario, it is called. I verified using this: https://github.com/rvagg/node-worker-farm/tree/master/examples/basic

What could be different?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu only setup this options https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/TaskRunner.js#L34 (as i written above)

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

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 process.send(). If I make it send a simple 'hello' instead of the entire minified script result it seems that all callbacks are called.

Making this callback with a shorter string results in all callbacks working:
https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/src/worker.js#L17

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.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@Pajn Maybe some characters break this πŸ˜•

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

@evilebottnawi Well, I just tested that by dumping the objects returned by the minify() worker functions to local .json files then trying to read each of them in simple workers in the basic example above, and then pass them on to the main process. Everything worked.

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 JSON.stringify(minify(...)) from the minify worker and those went through, but the first 1000000 characters made it hang.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

weird πŸ˜•

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

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?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu as workaround sounds good, but will be great find real problem why it is doesn't work as expected, maybe bug in WSL and we should report about this bug. Because on macos/linux/windows without WSL it is works as expected. So i think problem in WSL. If problem won't fix we implement workaround. Write files in temp directory decrease perf and it is not good.

from terser-webpack-plugin.

joewood avatar joewood commented on June 2, 2024

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.

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

On WSL:

$ node -pe 'os.tmpdir()'
/tmp

from terser-webpack-plugin.

joewood avatar joewood commented on June 2, 2024

I wonder if this fails under /mnt/c/Users/[windowsuser]/temp - which is (usually) NTFS.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@joewood maybe somebody has image for virtualbox with installed WSL?

from terser-webpack-plugin.

joewood avatar joewood commented on June 2, 2024

I can try later today on my regular machine as I'm seeing this issue too. I suspect this is a WSL bug, the idea of trying on the different disk formats is to compare on the WSL formatted disk vs. regular NTFS (which has some differences).

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

The problem is with interprocess communication not with anything file system related. /tmp isn't used. It was just a suggestion I made to use as a workaround so it is just hypothetical at this point.

I could not reproduce the error outside of webpack so I'm still not sure what the root cause is.

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

Take a look here for Windows VMs: https://developer.microsoft.com/en-us/windows/downloads/virtual-machines

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu already work on this, i will put information here

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Tested on latest version and all works fine, i think problem was fixed inside WSL

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Try to reproduce with #21 (comment)

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Parallels option works fine on latest WSL version

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

@evilebottnawi what Windows version are you testing on? 1903?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu virtual machine from windows, how i can get version of windows?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

I am trying to reproduce but can't, all work fine

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

Run winver in a command prompt or from run. Should say version 1809 or 1903.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu Version 1803 (OS Build 17134.706)

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu maybe you can create minimum reproducible test repo?

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

I'm also on 18031809, which is the currently widely available Windows version. 1903 is supposed to be released this month, and it has some WSL fixes, so maybe it might impact this issue. I haven't tested 1903 yet.

They also announced WSL2.0 which is a complete architecture change from WSL1.0 and whatever is causing this issue should be fixed by that, because it uses a real Linux kernel among other things. https://devblogs.microsoft.com/commandline/announcing-wsl-2/

That being said, I was just able to reproduce it on 18031809 using #21 (comment)

One thing to check (just suggesting it, since it looks like you're not a Windows guy :) - are you sure you're running under WSL and not the regular Command Prompt?

EDIT: Actually I'm on 1809, 1803 is an older release.

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

Attaching repro proof:

image

image

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu yes

node -e 'console.log(require("os").release())'
4.4.0-17134-Microsoft

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Investigate deeply, thanks for fast reply

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

@evilebottnawi actually, minor correction on my previous comment. I'm on 1809, not 1803. You're one version behind. If you definitely cannot reproduce it, that may point out why.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@andreialecu reproduce problem ⭐ WIP on fix

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

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

from terser-webpack-plugin.

endiliey avatar endiliey commented on June 2, 2024

I think #21 (comment) webpack config is defined/ constructed dynamically on @angular/cli which is another huge project.

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@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

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

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 😞

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

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

from terser-webpack-plugin.

andreialecu avatar andreialecu commented on June 2, 2024

Did you see 0% cpu for node processes for a very long time while you waited, and it eventually finished? Did you try with parallel: false?

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 ng build.

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 parallel: false works without huge performance penalties.

from terser-webpack-plugin.

endiliey avatar endiliey commented on June 2, 2024

I have been running it for 2 hours but it still stucks in 92%. Also 0% node process

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

@endiliey @andreialecu it is very strange, 20 min for #21 (comment) and all were minified, maybe you can create other minimum reproducible test repo?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

I am on SSD, maybe WSL has timeouts and in some cases it is failed πŸ˜•

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

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

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Somebody can test master version on WSL?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

Can't setup azure pipelines for WSL, if anyone had experience please put here πŸ˜„

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

/cc @Pajn can you test terser-webpack-plugin@2 on WSL? Thanks

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

/cc @andreialecu friendly ping, you are still on WSL?

from terser-webpack-plugin.

alexander-akait avatar alexander-akait commented on June 2, 2024

I am closing issue, if somebody will get an error, just open a new problem with a minimal example, thanks

from terser-webpack-plugin.

SebastienGllmt avatar SebastienGllmt commented on June 2, 2024

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.

from terser-webpack-plugin.

jerrodrs avatar jerrodrs commented on June 2, 2024

Upgraded my terser plugin from 1.3.5 to 2.3.5 and the issue is resolved, can use parallel now.

from terser-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.