hard-source-webpack-plugin icon indicating copy to clipboard operation
hard-source-webpack-plugin copied to clipboard

Try to fix a problem: Error: EMFILE: too many open files

Open zry656565 opened this issue 7 years ago • 1 comments

Expected Behavior

webpack build successfully.

Actual Behavior

03:51:24 $ yarn && node --stack_size=8192 --max-old-space-size=8192 ./node_modules/.bin/webpack --env.buildcache --env.hash --env.sourcemap hidden-nosources-source-map
03:51:24 [1/5] Validating package.json...
03:51:24 [2/5] Resolving packages...
03:51:25 success Already up-to-date.
03:51:26 Happy[js]: Version: 5.0.0. Threads: 4 (shared pool)
03:51:26 (node:3642) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
03:51:26 Happy[js]: All set; signaling webpack to proceed.
03:51:26 Happy[lessModule]: Version: 5.0.0. Threads: 4 (shared pool)
03:51:26 Happy[lessModule]: All set; signaling webpack to proceed.
03:51:26 Happy[less]: Version: 5.0.0. Threads: 4 (shared pool)
03:51:26 Happy[less]: All set; signaling webpack to proceed.
03:51:26 Happy[sourcemap]: Version: 5.0.0. Threads: 4 (shared pool)
03:51:26 Happy[sourcemap]: All set; signaling webpack to proceed.
03:51:26 [hardsource:2513388c] Tracking node dependencies with: yarn.lock, node_modules/*.
03:53:35 Error: EMFILE: too many open files, open '/var/lib/jenkins/workspace/basic-job/node_modules/.cache/hard-source/2513388c9b471d25f64e53cafc9ec34abb0934723d7d4fda903190a8bc7f97e1/stamp'
03:53:35 
03:53:35 error Command failed with exit code 1.
03:53:35 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Modules infomation

There're 6,000+ modules in our project.

Possible solution

Replace all native node fs with graceful-fs. It actually helps us fix this problem. Code: https://github.com/LeetCode-OpenSource/hard-source-webpack-plugin/commit/93143ca4e0e4ff069e5606ffba8c2d26565c2965

Is this a right way? And should I create a PR for this?

zry656565 avatar Sep 11 '18 11:09 zry656565

I guess this problem is mainly related to webpack itself, and just crash when hard-source-webpack-plugin wanna open some more files.

zry656565 avatar Sep 11 '18 11:09 zry656565