documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.io/jammit/
MIT License
1.16k stars 197 forks source link

Error 500 on first hit only to Jammit assets #188

Closed errows closed 13 years ago

errows commented 13 years ago

Hi, Every time I deploy to our staging or production server using capistrano, the first page load comes without any CSS or JS. It takes a very long time to load (server restart or asset packaging?). Looking at the console, I see that the assets http calls return a 500 error. Hoptoad logs the following error:

[GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/caching/sweeping.rb:82:in callback' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/caching/sweeping.rb:64:inafter' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:332:in around' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:315:in_callback_around_13' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:220:in _conditional_callback_around_649' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:431:in_run3409898037604311095process_action1199222331910899595callbacks' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:410:in _run_process_action_callbacks' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:94:inrun_callbacks' [GEM_ROOT]/gems/actionpack-3.0.7/lib/abstract_controller/callbacks.rb:17:in process_action' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/metal/instrumentation.rb:30:inblock in process_action' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/notifications.rb:52:in block in instrument' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/notifications/instrumenter.rb:21:ininstrument' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/notifications.rb:52:in instrument' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/metal/instrumentation.rb:29:inprocess_action' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/metal/rescue.rb:17:in process_action' [GEM_ROOT]/gems/actionpack-3.0.7/lib/abstract_controller/base.rb:119:inprocess' [GEM_ROOT]/gems/actionpack-3.0.7/lib/abstract_controller/rendering.rb:41:in process' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/metal.rb:138:indispatch' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/metal/rack_delegation.rb:14:in dispatch' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/metal.rb:178:inblock in action' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:62:in call' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:62:indispatch' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:27:in call' [GEM_ROOT]/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:148:inblock in call' [GEM_ROOT]/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:93:in block in recognize' [GEM_ROOT]/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:670:inoptimized_each' [GEM_ROOT]/gems/rack-mount-0.6.14/lib/rack/mount/code_generation.rb:92:in recognize' [GEM_ROOT]/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:139:incall' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/routing/route_set.rb:493:in call' [GEM_ROOT]/gems/sass-3.1.1/lib/sass/plugin/rack.rb:54:incall' [GEM_ROOT]/gems/warden-1.0.3/lib/warden/manager.rb:35:in block in call' [GEM_ROOT]/gems/warden-1.0.3/lib/warden/manager.rb:34:incatch' [GEM_ROOT]/gems/warden-1.0.3/lib/warden/manager.rb:34:in call' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/best_standards_support.rb:17:incall' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/head.rb:14:in call' [GEM_ROOT]/gems/rack-1.2.2/lib/rack/methodoverride.rb:24:incall' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/params_parser.rb:21:in call' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/flash.rb:182:incall' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/session/abstract_store.rb:149:in call' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/cookies.rb:302:incall' [GEM_ROOT]/gems/activerecord-3.0.7/lib/active_record/query_cache.rb:32:in block in call' [GEM_ROOT]/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/query_cache.rb:28:incache' [GEM_ROOT]/gems/activerecord-3.0.7/lib/active_record/query_cache.rb:12:in cache' [GEM_ROOT]/gems/activerecord-3.0.7/lib/active_record/query_cache.rb:31:incall' [GEM_ROOT]/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in call' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/callbacks.rb:46:inblock in call' [GEM_ROOT]/gems/activesupport-3.0.7/lib/active_support/callbacks.rb:416:in _run_call_callbacks' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/callbacks.rb:44:incall' [GEM_ROOT]/gems/rack-1.2.2/lib/rack/sendfile.rb:107:in call' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/remote_ip.rb:48:incall' [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_dispatch/middleware/show_exceptions.rb:47:in call' [GEM_ROOT]/gems/railties-3.0.7/lib/rails/rack/logger.rb:13:incall' [GEM_ROOT]/gems/rack-1.2.2/lib/rack/runtime.rb:17:in call' [GEM_ROOT]/gems/rack-1.2.2/lib/rack/lock.rb:11:inblock in call' : [GEM_ROOT]/gems/rack-1.2.2/lib/rack/lock.rb:11:in call' [GEM_ROOT]/gems/dragonfly-0.8.2/lib/dragonfly/middleware.rb:16:incall' [GEM_ROOT]/gems/railties-3.0.7/lib/rails/application.rb:168:in call' [GEM_ROOT]/gems/railties-3.0.7/lib/rails/application.rb:77:inmethod_missing' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/request_handler.rb:96:in process_request' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:513:inaccept_and_process_next_request' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_request_handler.rb:274:in main_loop' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:205:instart_request_handler' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:170:in block in handle_spawn_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/utils.rb:479:insafe_fork' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:165:in handle_spawn_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in start_synchronously' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:180:instart' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/rack/application_spawner.rb:128:in start' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:253:inblock (2 levels) in spawn_rack_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:132:in lookup_or_add' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:246:inblock in spawn_rack_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:82:in block in synchronize' : /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server_collection.rb:79:insynchronize' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:244:in spawn_rack_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:137:inspawn_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/spawn_manager.rb:275:in handle_spawn_application' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:357:inserver_main_loop' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/lib/phusion_passenger/abstract_server.rb:206:in start_synchronously' /home/passenger/.rvm/gems/ruby-1.9.2-p180/gems/passenger-3.0.7/helper-scripts/passenger-spawn-server:99:in

'

We are also using acts_as_audited, which is also using a sweeper. We are using jammit 0.6.3

Any help would be appreciated, a this point we are quite clueless. Thanks everyone.

errows commented 13 years ago

Hi, Can we provide more details to help someone figure this out? We still haven't found a solution.

Thank you, Marc-Antoine

jashkenas commented 13 years ago

Looks like the error is coming from "[GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/caching/sweeping.rb" ... which would be the sweeper you're using. You didn't mention what the error actually was. From the stacktrace, I don't see what this has to do with Jammit.

errows commented 13 years ago

Hi Jeremy, The error is raised when my browser tries to reach the CSS files packaged by Jammit the first time (/assets/frontend.css). Calling this URL returns an error 500 the first hit and returns the CSS properly the second time. The stack trace above is what is logged when I get the error 500.

Why did you close the issue?

Thank you

jashkenas commented 13 years ago

The stack trace doesn't include the error message, which would tell you what the error actually was, inside of sweeping.rb at line 82. Even if it did tell you what the error was, it would be an error in the sweeper, not in Jammit -- I'm afraid there's no way for me to help you with it.

errows commented 13 years ago

NoMethodError: undefined method `controller_name' for nil:NilClass Action jammit#package File [GEM_ROOT]/gems/actionpack-3.0.7/lib/action_controller/caching/sweeping.rb:82 {"extension"=>"css", "action"=>"package", "package"=>"frontend", "controller"=>"jammit"}

I understand the error is not in the Jammit gem, but still caused by Jammit.

errows commented 13 years ago

Jeremy, Can we re-open this issue. I do believe the issue is caused by Jammit and would love to fix it. Thank you Marc-Antoine

errows commented 13 years ago

Jeremy, believe it or not, I finally found the problem. Our application already has an AssetsController. Changing the package_path as described in the documentation fixed this issue with Jammit.

Thought I would share for others...