ruby-on-railsexecjs

rails hangs in development mode, ExecJS


My project suddenly began to hang out on page loads, in development mode. The behavior is very strange, the browser or curl just processing the request. I desperate.

Caching is turned off.

I took config/environments/development.rb from new empty rails project.

I think the blame ExecJS, beacues when I remove line

javascript_include_tag 'backend', 'data-turbolinks-track' => true

from layout file everything works fine. The most outrageous thing is that I nothing changed in javascript for a while.

I tried remove NodeJS from system and add gem 'therubyracer' to Gemfile

But nothing changed.

Sometimes even Ctrl+C does not stop the server and I have to close the window with the console with rails server.

Now execute rails with this command

rm -rf tmp/* && rails server

Help me please.

P.S. ruby 2.2.0p0, rails 4.2, ubuntu x64.


Solution

  • The problem was in assets.

    /config/initializers/assets.rb

    config.assets.js_compressor = Uglifier.new(comments: :none) 
    config.assets.compile = true
    

    I tried to compress javascript on every request.

    Solution, move this 2 lines in to /config/environments/production.rb

    Stupid mistake, which is very hard to find.