Closed afuno closed 6 years ago
Are you using es6 code or any libraries that probably using es6 code? See this issue: https://github.com/rails/webpacker/issues/306
@gauravtiwari I'll read it all and test. But why can not I get a normal error text in the log? It looks very strange.
P.S.: As for the link you gave me, I'll answer you soon.
The other thing you could do is compile like so locally:
NODE_ENV=production bundle exec rails assets:precompile
This will compile in production mode and will display appropriate errors.
@gauravtiwari
The first thing I tested it locally:
NODE_ENV=production RAILS_ENV=production rake assets:precompile
This command was copied directly from the log to save its appearance:
rake assets:precompile
All successfully compiled.
@gauravtiwari I brought the .babelrc file to this form:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 10"],
"node": "current",
"uglify": true
},
"useBuiltIns": true
}],
"stage-2",
"es2015"
],
"plugins": [
"transform-runtime",
["module-resolver", {
"root": ["./"],
"alias": {
"app_assets": "./app/assets",
"vendor_assets": "./vendor/assets"
}
}]
],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["istanbul"]
}
}
}
It did not help.
Also the file yarn.lock: https://pastebin.com/raw/y0Z21sv0
yarn add babel-plugin-transform-function-bind
Too has not helped.
@gauravtiwari It is impossible to do anything without the text of the error. Even under your link the author has an error text. I do not have anything. Just one line that does not give absolutely nothing:
Precompiling assets failed.
I do not understand what to do about it :( Just at one point everything stopped working. And I did not even touch the files associated with the deploy.
This also did not help: http://babeljs.io/env
Just to give some context, I too am running into this issue. I am not running it via heroku but on alpine linux docker container. I get the error
Compiling…
Compilation failed:
With no informative error.
This error started happening when I upgrade webpacker from 3.0.2 to 3.2.0. I suspect one of the dependencies that was updated on this release caused an issue.
from the yarn.lock file
"@rails/webpacker@^3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@rails/webpacker/-/webpacker-3.2.0.tgz#e9e98a4da4a3e09441c71d2cbd66461659971055"
dependencies:
babel-core "^6.26.0"
babel-loader "^7.1.2"
babel-plugin-syntax-dynamic-import "^6.18.0"
babel-plugin-transform-class-properties "^6.24.1"
babel-plugin-transform-object-rest-spread "^6.26.0"
babel-polyfill "^6.26.0"
babel-preset-env "^1.6.1"
case-sensitive-paths-webpack-plugin "^2.1.1"
compression-webpack-plugin "^1.0.1"
css-loader "^0.28.7"
extract-text-webpack-plugin "^3.0.2"
file-loader "^1.1.5"
glob "^7.1.2"
js-yaml "^3.10.0"
node-sass "^4.7.2"
path-complete-extname "^0.1.0"
postcss-cssnext "^3.0.2"
postcss-import "^11.0.0"
postcss-loader "^2.0.9"
sass-loader "^6.0.6"
style-loader "^0.19.0"
webpack "^3.10.0"
webpack-manifest-plugin "^1.3.2"
When I run webpack directly I get a bit more informative error
> bundle exec webpack
> Segmentation fault
Right now I'm suspecting this is the culprit and am digging further. https://github.com/sass/node-sass/issues/2169
Hope this is helpful to everyone and see if we can all come up with a solution.
@IsaaX The problem is that I created a new Rails application:
rails new MyNewApp --webpack=vue
That is, I did not update the Webpacker.
And in the new Rails application I copied the app directory from the old one. Without touching Webpacker configs.
@afuno I presume since you are on a new application you are on webpacker v3.2.0? That's partially the issue but that's only speculation. If not could you let us know the version you are on?
@IsaaX This command:
NODE_ENV=production RAILS_ENV=production bundle exec webpack
Locally everything successfully compiles (displays information) (as minify).
Yes. Version 3.2.0. Actual to the moment.
@afuno ok so far my suspicious are on the right track. Locally my assets compile successfully. I'm running Mac OSX 10.12.6 High Sierra.
Only when I'm on a docker container with alpine linux does the asset compilation fails, which seems to be the case with you too since you are trying to deploy to heroku. The images heroku uses are linux based. So looking at https://github.com/sass/node-sass/issues/2169 it seems that the node version is not high enough.
@IsaaX
OS:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Dokku (.buildpacks) container:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
Could you please try this code in webpack/production.js
?
# from terminal
yarn add uglifyjs-webpack-plugin
// config/webpack/production.js
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const environment = require('./environment')
environment.plugins.delete('UglifyJs')
environment.plugins.append(
'UglifyJs',
new UglifyJsPlugin({
sourceMap: true
})
)
module.exports = environment.toWebpackConfig()
And then deploy again.
@gauravtiwari I did it, but it did not help.
And: node_modules/@rails/webpacker/package/environments/production.js
Ahh right. It should be in config/webpack/production.js
Please could you set ecma
to 8 or 7: https://github.com/webpack-contrib/uglifyjs-webpack-plugin#uglifyoptions
new UglifyJsPlugin({
uglifyOptions: {
ie8: false,
ecma: 8,
warnings: false
}
})
@gauravtiwari Did not help:
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const environment = require('./environment')
environment.plugins.delete('UglifyJs')
environment.plugins.append(
'UglifyJs',
new UglifyJsPlugin({
uglifyOptions: {
ie8: false,
ecma: 7, // or 8
warnings: false
}
})
)
module.exports = environment.toWebpackConfig()
I do not know what to do... The project simply does not start on the server...
Does it compile now or still same error? Compilation failed
@gauravtiwari Absolutely the same thing. Nothing new.
Aahhrrggh! Can you give me access to your repo may be? (if that's okay) or make a public example to debug the problem.
@gauravtiwari Maybe it's RAM? I have 4 Gb RAM on the server. The server has Dokku, and Dokku has one application. This application has a link to the database (PostgreSQL) and Redis.
The process of compiling assets looks like this, that at one point (not immediately) the compilation falls.
It looks like a lack of RAM (4 Gb). But this is strange, since there are a lot of it on the server.
@gauravtiwari Oh my God!
For the thousandth time, I start the process of deploy. But this time I opened the server console in parallel (top
).
The compilation (node) did not eat more than 12 percent of the RAM.
As a result, the compilation was successful! Deploy completed!
And the strangest thing is that I did not do anything. You can see for yourself. What is this devilry? :D
Most likely it's RAM. But I can not understand why now everything went well. I'm afraid to take the next deploy D:
@afuno Yes that's another thing I totally forgot to mention, there are some issues filed on the repo that's related to memory (RAM) not being sufficient for compilation. Is it deploying okay now?
@gauravtiwari Today the second deployment was successful.
@gauravtiwari Periodically falls. I have to sit during the deployment and shake the tambourine. It's just like a lottery.
Have you tried upgrading RAM to say 1GB or 2GB? The other alternative is you compile everything locally and push it to source control.
@gauravtiwari So I have 4 Gb of RAM on the server.
Closing this for now.
@gauravtiwari This problem has just appeared in the second project. The second project I created the other day. Also Rails 5.1.4. Deployment was canceled for the same reason.
When deployed, a maximum of 12% of server RAM (for node) is consumed.
P.S. I do not think that this topic should be closed, because the problem is not solved.
During the deployment: screenshot One second before the fall: screenshot
After I made the second deployment screenshot fell.
Ahh thanks @afuno for update. Are you still getting same cryptic error message? Does Dokku supports deploying in verbose mode so you can see why compilation fails?
Perhaps, consider posting this issue on webpack repo since webpacker is nothing more than a wrapper around latest webpack.
I just deployed an example app on heroku and it's deployed fine.
@gauravtiwari I use Dokku recommendations for deployment (git commands). Moreover, I spent half a year deploying with the Webpacker without any problems. I've used Webpacker 3.2 since its release. And everything was wonderful.
But since January 11 this year, I began to receive this problem.
@afuno thanks, so you started having these problems after 3.2.0? Could you please try 3.2.1?
@gauravtiwari I already tried the 3.2.1 version. Did not help.
@gauravtiwari Oh my God. I really do not understand what kind of crap :D The application has just deployed in seconds (Webpack compiling). The server state was exactly the same as yesterday, the day before yesterday, a week ago...
I do not understand anything.
Although exactly an hour ago I barely deployed the application D:
I have the same error. This is very strange. I also use dokku for deploy. This was a new app. I have deployed it successfully, but after 2 hours can't do it again. This is very, very strange =) I have rails 6.0.. and webpacker from the master branch "@rails/webpacker": "https://github.com/rails/webpacker"
This was a new app. I have deployed it successfully, but after 2 hours can't do it again.
Keep in mind that builds and deps act differently depending on NODE_ENV
.
@afuno @vitalyliber Can you see if this works?
new UglifyJsPlugin({
uglifyOptions: {
compress: {
collapse_vars: false
}
}
}
)
Solves issues related to: https://github.com/terser-js/terser/issues/50
Many asset-heavy npm packages have this problem but, since webpacker compiles all node_modules
by default, it only takes one bad dependency or sub-dependency for your build to choke to death.
TL;DR: When "dead code elimination" is run, there are so many code elimination candidates to keep track of that your process runs out of memory (cc @gauravtiwari). We ran into this while building FontAwesome for production, they have a good guide about overcoming this.
Hello.
I suddenly began to receive error when deploy. For several days now I can not understand what's wrong.
First I tried to fix my Rails application (configuration). But today I created a new application:
And then I restored some files: views, models, controllers, javascript (for webpack) and so on.
It is worthwhile to clarify that locally I have always compiled (javascript for webpack) everything. But on the server I was getting an error.
I do not have any custom settings for Webpack. Just what the team generated, which I showed above.
But there are new files that I created myself:
.babelrc:
.postcssrc.yml:
By the way, about deploy. On the server I use Dokku. And deploy based on buildpacks.
.buildpacks:
Now about the error. Here is the full log of deploy:
Help me solve the problem. I'm desperate and I do not know what to do.