{"id":6369,"date":"2014-04-17T00:58:05","date_gmt":"2014-04-17T00:58:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/17\/rails-3-1-intermittent-500-internal-server-error-when-serving-uncompressed-assets-collection-of-common-programming-errors\/"},"modified":"2014-04-17T00:58:05","modified_gmt":"2014-04-17T00:58:05","slug":"rails-3-1-intermittent-500-internal-server-error-when-serving-uncompressed-assets-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/17\/rails-3-1-intermittent-500-internal-server-error-when-serving-uncompressed-assets-collection-of-common-programming-errors\/","title":{"rendered":"Rails 3.1: Intermittent 500 Internal Server Error when serving uncompressed assets-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m upgrading an app to Rails 3.1. Quote often, Firebug will complain about some assets. Here are some errors pasted from Firebug:<\/p>\n<pre><code>\"NetworkError: 500 Internal Server Error - http:\/\/unstilted.dev\/assets\/jquery-ui.js?body=1\"\njquery...?body=1\n\"NetworkError: 500 Internal Server Error - http:\/\/unstilted.dev\/assets\/admin\/pages\/file_attachments.js\"\nfile_a...ents.js\n\"NetworkError: 500 Internal Server Error - http:\/\/unstilted.dev\/assets\/admin\/file_attachments\/sortable.js?body=1\"\nsortab...?body=1\n\"NetworkError: 500 Internal Server Error - http:\/\/unstilted.dev\/assets\/jquery.js?body=1\"\n<\/code><\/pre>\n<p>Refreshing the page would yield different assets showing the same error. When I copy and paste the URL I see the files just fine.<\/p>\n<p>I&#8217;m using:<\/p>\n<ul>\n<li>Ubuntu 11.04<\/li>\n<li>Apache+Passenger 3.0.9<\/li>\n<\/ul>\n<p><strong>How do I fix this?<\/strong><\/p>\n<p><strong>UPDATE<\/strong>: Log file<\/p>\n<p>In this particular instance, <code>jquery-ui.js<\/code> was showing an error in Firebug. My log file looked like this:<\/p>\n<pre><code>Started GET \"\/assets\/jquery.js?body=1\" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011\nServed asset \/jquery.js - 304 Not Modified (0ms)\n\n\nStarted GET \"\/assets\/jquery_ujs.js?body=1\" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011\n\n\nStarted GET \"\/admin\/site\/sites\/storage.js\" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011\nServed asset \/jquery_ujs.js - 304 Not Modified (0ms)\n\n\nStarted GET \"\/assets\/application.js?body=1\" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011\n  Processing by Admin::Site::SitesController#storage as JS\nServed asset \/application.js - 304 Not Modified (3ms)\n  ...\nRendered admin\/site\/sites\/storage.js.erb (0.1ms)\nCompleted 200 OK in 58ms (Views: 5.1ms | ActiveRecord: 21.1ms)\n\n\nStarted GET \"\/assets\/admin\/logo.png\" for 127.0.0.1 at Tue Sep 06 22:24:39 +0800 2011\nServed asset \/admin\/logo.png - 304 Not Modified (0ms)\n<\/code><\/pre>\n<p>It seems to have skipped <code>jquery-ui.js<\/code>!<\/p>\n<p><strong>UPDATE<\/strong> Oct 1, 2011:<\/p>\n<p>I tried it out with the standalone passenger (<code>passenger start<\/code>) as it seems to give a more descriptive error. This is what happens when I try to load just the <code>jquery.js<\/code> file and press <code>CTRL-R<\/code> repeatedly to refresh my browser and load that asset repeatedly.<\/p>\n<pre><code>Started GET \"\/assets\/jquery.js?body=1\" for 127.0.0.1 at 2011-10-01 21:40:18 +0800\n[ pid=29485 thr=3066030960 file=ext\/nginx\/HelperAgent.cpp:931 time=2011-10-01 21:40:18.691 ]: Uncaught exception in PassengerServer client thread:\n   exception: Cannot read response from backend process: Connection reset by peer (104)\n   backtrace:\n     in 'void Client::forwardResponse(Passenger::SessionPtr&amp;, Passenger::FileDescriptor&amp;, const Passenger::AnalyticsLogPtr&amp;)' (HelperAgent.cpp:603)\n     in 'void Client::handleRequest(Passenger::FileDescriptor&amp;)' (HelperAgent.cpp:857)\n     in 'void Client::threadMain()' (HelperAgent.cpp:950)\n\n2011\/10\/01 21:40:18 [error] 29522#0: *16 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: _, request: \"GET \/assets\/jquery.js?body=1 HTTP\/1.1\", upstream: \"passenger:unix:\/passenger_helper_server:\", host: \"get.unstilted.dev:3000\"\n[ pid=29674 thr=78131090 file=utils.rb:176 time=2011-10-01 21:40:18.699 ]: *** Exception PGError in application (server closed the connection unexpectedly\n        This probably means the server terminated abnormally\n        before or while processing the request.\n) (process 29674, thread #):\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/postgresql_adapter.rb:276:in `exec'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/postgresql_adapter.rb:276:in `block in clear_cache!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/postgresql_adapter.rb:275:in `each_value'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/postgresql_adapter.rb:275:in `clear_cache!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/postgresql_adapter.rb:303:in `disconnect!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:202:in `block in disconnect!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:201:in `each'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:201:in `disconnect!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activesupport-3.1.0\/lib\/active_support\/core_ext\/module\/synchronization.rb:35:in `block in disconnect_with_synchronization!'\n        from \/home\/ramon\/.rvm\/rubies\/ruby-1.9.2-p290\/lib\/ruby\/1.9.1\/monitor.rb:201:in `mon_synchronize'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activesupport-3.1.0\/lib\/active_support\/core_ext\/module\/synchronization.rb:34:in `disconnect_with_synchronization!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:395:in `block in clear_all_connections!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:395:in `each_value'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:395:in `clear_all_connections!'\n        from \/home\/ramon\/.rvm\/gems\/ruby-1.9.2-p290@unstilted\/gems\/activerecord-3.1.0\/lib\/active_record\/connection_adapters\/abstract\/connection_specification.rb:123:in `clear_all_connections!'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/utils.rb:398:in `before_handling_requests'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/rack\/application_spawner.rb:204:in `start_request_handler'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/rack\/application_spawner.rb:170:in `block in handle_spawn_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/utils.rb:479:in `safe_fork'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/rack\/application_spawner.rb:165:in `handle_spawn_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server.rb:357:in `server_main_loop'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server.rb:206:in `start_synchronously'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server.rb:180:in `start'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/rack\/application_spawner.rb:128:in `start'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/spawn_manager.rb:253:in `block (2 levels) in spawn_rack_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server_collection.rb:132:in `lookup_or_add'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/spawn_manager.rb:246:in `block in spawn_rack_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server_collection.rb:82:in `block in synchronize'\n        from :10:in `synchronize'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server_collection.rb:79:in `synchronize'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/spawn_manager.rb:244:in `spawn_rack_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/spawn_manager.rb:137:in `spawn_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/spawn_manager.rb:275:in `handle_spawn_application'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server.rb:357:in `server_main_loop'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/lib\/phusion_passenger\/abstract_server.rb:206:in `start_synchronously'\n        from \/home\/ramon\/.passenger\/standalone\/3.0.9-x86-ruby1.9.2-linux-gcc4.5.2-1002\/support\/helper-scripts\/passenger-spawn-server:99:in `'\nServed asset \/jquery.js - 304 Not Modified (0ms)\ncache: [GET \/assets\/jquery.js?body=1] stale, valid, store\n[ pid=29485 thr=3064224624 file=ext\/nginx\/HelperAgent.cpp:921 time=2011-10-01 21:40:18.734 ]: Couldn't forward the HTTP response back to the HTTP client: It seems the user clicked on the 'Stop' button in his browser.\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m upgrading an app to Rails 3.1. Quote often, Firebug will complain about some assets. Here are some errors pasted from Firebug: &#8220;NetworkError: 500 Internal Server Error &#8211; http:\/\/unstilted.dev\/assets\/jquery-ui.js?body=1&#8221; jquery&#8230;?body=1 &#8220;NetworkError: 500 Internal Server Error &#8211; http:\/\/unstilted.dev\/assets\/admin\/pages\/file_attachments.js&#8221; file_a&#8230;ents.js &#8220;NetworkError: 500 Internal Server Error &#8211; http:\/\/unstilted.dev\/assets\/admin\/file_attachments\/sortable.js?body=1&#8221; sortab&#8230;?body=1 &#8220;NetworkError: 500 Internal Server Error &#8211; http:\/\/unstilted.dev\/assets\/jquery.js?body=1&#8221; Refreshing the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6369","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6369"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6369\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}