unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
* Bug in unicorn_rails when Encoding.default_internal is set
@ 2012-02-17  2:29 Lucas Parry
  2012-02-17  2:37 ` Lucas Parry
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Parry @ 2012-02-17  2:29 UTC (permalink / raw)
  To: mongrel-unicorn

Hi,

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:

    https://github.com/lparry/how_to_kill_a_unicorn

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?

Cheers,

Lucas Parry
Envato
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug in unicorn_rails when Encoding.default_internal is set
  2012-02-17  2:29 Bug in unicorn_rails when Encoding.default_internal is set Lucas Parry
@ 2012-02-17  2:37 ` Lucas Parry
  2012-02-17  3:59   ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Parry @ 2012-02-17  2:37 UTC (permalink / raw)
  To: mongrel-unicorn

On Fri, Feb 17, 2012 at 1:29 PM, Lucas Parry <lucas@envato.com> wrote:
> We recently made the switch to 1.9 for our large rails 2.3.14 project

I guess I should be more precise; This problem is occurring on MRI1.9.2-p290
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Bug in unicorn_rails when Encoding.default_internal is set
  2012-02-17  2:37 ` Lucas Parry
@ 2012-02-17  3:59   ` Eric Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2012-02-17  3:59 UTC (permalink / raw)
  To: unicorn list; +Cc: Lucas Parry

Lucas Parry <lucas@envato.com> wrote:
> On Fri, Feb 17, 2012 at 1:29 PM, Lucas Parry <lucas@envato.com> wrote:
> > We recently made the switch to 1.9 for our large rails 2.3.14 project

(odd, neither I nor gmane got your original message:
 http://rubyforge.org/pipermail/mongrel-unicorn/2012-February/001310.html
 Perhaps Mailman misdelivers UTF-8...
)

> I guess I should be more precise; This problem is occurring on MRI1.9.2-p290

Setting Encoding.default_* is probably a bad idea in your app.
If you run Ruby with warnings (-w switch), you'll see setting
Encoding.default_* will generate warnings to discourage their use.

If you want UTF-8, set LANG=en_US.UTF-8 in the environment _before_
starting Ruby, which will only set Encoding.default_external.

I've always just left Encoding.default_internal alone.  I'll let others
on the list with more Rails/encoding experience help you with that.

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

Seems to be Rails bug.  Rails 3.2.1 seems to handle the situation
without difficulty.


Fwiw, neither Rack nor HTTP specify an encoding for HTTP headers/paths.
The only place where encoding is specified for Rack is "rack.input",
which must be binary.  There was talk on the Rack mailing list a long
while back about enforcing encodings for certain headers, but nothing
came of it.
_______________________________________________
Unicorn mailing list - mongrel-unicorn@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-17  6:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-17  2:29 Bug in unicorn_rails when Encoding.default_internal is set Lucas Parry
2012-02-17  2:37 ` Lucas Parry
2012-02-17  3:59   ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).