breezewish / express-minify

Automatically minify and cache your javascript and css files.
https://npmjs.org/package/express-minify
MIT License
86 stars 18 forks source link

Crash #54

Open martinlevesque opened 7 years ago

martinlevesque commented 7 years ago

I am sometimes getting the following js stack when it crashes:

-- ==== JS stack trace =========================================

Security context: 0x1eebfa29cca1 1: indexOf(this=0x8003cb8acb9 <Very long string[120432959]>) 2: cssmin [/home/1/www/node_modules/cssmin/cssmin.js:~28] [pc=0x30c7f5977e84](this=0x3443744b0189 ,css=0x2bd8de31baa9 <Very long string[20809655]>,linebreakpos=0x1eebfa282241 ) 3: arguments adaptor frame: 1->2 5: / anonymous / [/home/1/www/node_modules/express-minify/minifier....

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

--

any idea how to fix it?

I am using express-minify 0.2.0. I see there were new versions - is this issue known/fixed?

thanks

breezewish commented 7 years ago

Hi, this is out of memory error. Your application hit the default Nodejs memory limit and it crashed. This may caused by several issues, for example,

  1. There might be a memory leak in cssmin or uglifyjs
  2. You are serving a big file so that cssmin or uglifyjs needs large amount of memory to do minification
  3. You are not using disk cache so that express-minify keeps a lot of content in memory

Ways to solve:

  1. Make sure you enabled disk cache
  2. You can adjust NodeJs start up arguments to allow NodeJs using more memory
  3. Update express-minify to use latest version of those minifiers (and hope those new versions have less memory leaks)
martinlevesque commented 7 years ago

Hi,

Thanks for the response. I will try your potential solutions. I already tried to increase max-old-space-size but without success.

I disabled temporarily the minification to avoid crashing, as I have several other things to do currently. I will report whenever I get back to it.