Intermittent “premature end of script headers” with Rails 3.1

时光总嘲笑我的痴心妄想 提交于 2019-12-10 18:35:49

问题


So I've started upgrading our app to Rails 3.1 from Rails 3.0.9.

It's working great in the development environment. The time has come to put it up onto the staging server so we can run some full acceptance tests -- but oh, no! We're getting the horrible "Internal Server Error" pages served back at us half of the time, seemingly randomly. We're using Ruby 1.9.2 (p290) Apache (2) and Passenger (3.0.9).

Absolutely nothing is being written to our app's log file when these happen (even at the lowest log level).

The only thing being written to the Apache log is the following:

[Fri Dec 02 14:36:15 2011] [error] [client <my ip>] Premature end of script headers: <requested path>, referer: <http://domain.com/referrer>

Obviously this is far too generic an error for me to ask "fix it!", but some advice on where I can start looking to debug what's going on would be greatly appreciated. This is driving me nuts.

UPDATE: This problem does not occur with Sprockets disabled (i.e. config.assets.enabled = false) Never mind, it still does...


回答1:


I found what was causing it.

It seems this is a problem with Rack middleware. A gem somewhere along the chain was breaking stuff (in my case it was the Airbrake (formerly known as Hoptoad) gem, which may explain why no exception was being logged anywhere). Removing the errant gem or updating it to the latest version (installing from git rather than the canonical rubygems source) fixed it for me.

If anyone else stumbles upon this issue, I'd advise you to check that part of your stack.




回答2:


Try reading through this, and seeing if it gains you any insight: http://htmlfixit.com/cgi-tutes/tutorial_Common_Web_dev_error_messages_and_what_they_mean.php#premature



来源:https://stackoverflow.com/questions/8358280/intermittent-premature-end-of-script-headers-with-rails-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!