Webpacker: Compilation Failed without error message

Created on 16 Oct 2017  ·  22Comments  ·  Source: rails/webpacker

Hello

I have a problem using rails 5.1, webpacker and Vue2.js during deployment to a digital ocean ubuntu droplet. The compilation process fails without an error message. Sometimes the whole process hangs during compilation and I have to reboot the server. The application is very basic with little additional code or configuration other than what's standard out of the box.

See also this stackoverflow question for more details. You can see the code here.

Most helpful comment

In case anyone else runs into this, I had to set webpack_compile_output: true in webpacker.yml for rails assets:precompile to output anything on failure.

I don't really understand why it wouldn't be outputting things regardless of that option on failure, but 🤷‍♂

All 22 comments

@schepens83 Please consider bumping up the instance memory or compile your assets locally and then push it to production. Webpack uses considerable amount of memory during compilation.

@gauravtiwari Thanks for the tip. I take it you mean I run bin/bundle exec webpacker:compile locally. Check in the new files in the git repo and push to server? How do I prevent the webpacker:compile to run when I run RAILS_ENV=production bin/bundle exec rake assets:precompile on the server?

If you compile your assets locally, then you don't need to run - RAILS_ENV=production bin/bundle exec rake assets:precompile on the server

Just run this locally - RAILS_ENV=production bin/bundle exec rake assets:precompile and then commit the assets to git and deploy it to production.

@gauravtiwari Alright, that solved it! Thanks for the help.

For future viewers; simple thing, but I had to delete the automatically added public/packs/ line from my .gitignore file, to make it work.

@gauravtiwari Just as an additional question. How much (additional/total) memory would the droplet require to stop having this problem?

@schepens83 Depends on how big the app is, but please try bumping up to 1GB and see if that solves the problem.

just bumping the memory size solved my problem, thanks @gauravtiwari

Why is it failing without an error message? The OP might have resolved their issue, but this is still a bug as far as I can tell.

Why is it failing without an error message? The OP might have resolved their issue, but this is still a bug as far as I can tell.

👆 This! I had to dig up here to find it might be a memory issue.

This issue might also come up more often then you think. My app has about 10 React components, 3 reducers and I'm hitting this problem on Heroku. (I'm not yet sure it's a memory limitation but the compilation works correctly locally.)

@betaflag @ch-tactica Error details were suppressed to reduce dev server output in development: https://github.com/rails/webpacker/pull/1834#issuecomment-447502581. I didn't agree with that choice, but perhaps a PR with supporting evidence from an actual app would make a better case than I did.

If you want to skip to a solution, here are a few things that can make your output more detailed: https://github.com/rails/webpacker/issues/1824#issuecomment-443796163

In case anyone else runs into this, I had to set webpack_compile_output: true in webpacker.yml for rails assets:precompile to output anything on failure.

I don't really understand why it wouldn't be outputting things regardless of that option on failure, but 🤷‍♂

this helped a lot, devs PLEASE make logging default to ON for production. I fought this for a week to find it was a missing file.

Such a terrible decision to remove this by default, it really fucked me up!

Excuse my french!

Such a terrible decision to remove this by default, it really fucked me up!

Agreed! Adding @connorshea's webpacker.yml config suggestion helped me find the actual problem immediately. Removing this was an awful decision.

My app faced webpacker compiled failed but no details message.
webpack_compile_output: true is already set

Would anyone mind to help me on how to get details message please?

For those who run the precompilation step in Dockerfile, set compile to false in webpacker.yml to avoid running it twice. Happened with us in staging, where by default the compile is set to true and it kept running out of memory.

@andresuchitra Not sure if this helps, but I just ran into a silent failure because I didn't have yarn installed on the server.

I'm running this on CircleCI 2.0, getting a silent failure with webpack_compile_output: true already set. Furthermore, it's not failing on every build - it's often successful on reruns. It logs a bunch of stuff when it's successful and just fails silently when it does fail (most of the time).

Compiling…

Compilation failed:






Exited with code exit status 1 
CircleCI received exit code 1 

I suspect it might be a memory issue, but haven't had the time to really research it that much yet.

Edit: seems to have been a resource issue indeed, it was resolved after we upgraded our plan over the weekend

@Tuuleh It seems webpack is taking too much memory so if you're on a small server it will go out of memory and the process will be killed. The solution is to tell node to use small amount of memory by defining this env var NODE_OPTIONS="--max-old-space-size=350"
U can read more here...

Thanks for everyone's contributes.

As @Tuuleh said, it was caused by lacking of enough memory.

@ciremoussadia offers a great solution if you cannot increase machine's memory.
However, 350M memory may be too small for some cases. You may try a big number.
It helps us after increasing to 4096, NODE_OPTIONS="--max-old-space-size=4096"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilrock picture ilrock  ·  3Comments

ankitrg picture ankitrg  ·  3Comments

johan-smits picture johan-smits  ·  3Comments

suhomozgy-andrey picture suhomozgy-andrey  ·  3Comments

eriknygren picture eriknygren  ·  3Comments