Bug in unicorn_rails when Encoding.default_internal is set

Lucas Parry lucas at envato.com
Thu Feb 16 21:29:01 EST 2012


We recently made the switch to 1.9 for our large rails 2.3.14 project
and ran into some strange behavior from the unicorns where encoding
problem would cause blank 500 pages to be "randomly" served to users
(we run ~10 x 5 unicorn workers behind our load balancer). We found
that unicorn workers were dying when someone requested a url with
utf-8 in it, and died in such a way that subsequent requests to that
worker would get the same blank 500 page even for plain ascii urls.

I've been able to recreate this behavior one a fresh rails project by
setting Encoding.default_internal to utf-8 and very little else. I've
created an example repo at:


All you need to do is hit http://localhost:8080/users/☃ and the
unicorn worker will die with an error:

"Error during failsafe response: "\xE2" from ASCII-8BIT to UTF-8"
"app error: "You have a nil object when you didn't expect it!\nYou
might have expected an instance of Array.\nThe error occurred while
evaluating nil.each" (NoMethodError)"

All subsequent requests to that worker will fail with the same exception.

Is this a known issue? Is there a recommended work around?


Lucas Parry

More information about the mongrel-unicorn mailing list