Ruby 1.9.1-p234/Passenger 2.2.5 tempfile.rb fix

Got bit by an annoying bug when I upgraded Passenger earlier today. GET requests work fine, but POST requests would not get through to Rails, instead crash with a repeatable:

closed stream
/usr/local/lib/ruby/gems/1.9.1/gems/passenger/vendor/rack-1.0.0-
git/lib/rack/rewindable_input.rb:86:in `make_rewindable'

This happens with Nginx 0.8.13 (edge) and 0.7.61 (last stable), Passenger 2.2.5 and Ruby 1.9.1-p234. The problem seems to be the later. It turns out Windows and Unix (more specifically POSIX) handle tempfiles differently. You can guess which OS does a better job.

At any rate, Ruby 1.9.1-p234 decided to revert to Windows-like behavior (unlink closes), which caused Rack to lose hold of its temporary files. The solution, while we all wait for a new release of Ruby 1.9.1 is to nix line 140 in tempfile.rb.

2 thoughts on “Ruby 1.9.1-p234/Passenger 2.2.5 tempfile.rb fix

  1. Oh, nice find, thank you. Had this same issue and had no idea how to solve it. Not a fan of hacking Ruby, but when it comes down to working or not working you do what you gotta do.

  2. Thank you so much for this, I’ve been battling with getting this to work for a while now and as always assumed I had done something wrong!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>