synchronous controllers taking 6 seconds in Eventmachine config

Eric Wong normalperson at
Wed Sep 15 14:50:07 EDT 2010

Christoph Sturm <me at> wrote:
> hello rainbows friends!
> we use rainbows in eventmachine mode, and it seems there's a bug in
> handling of synchronous responses.
> this controller takes 6 seconds:
> def call(env)
> end
> this only occurs when i dont set a content length, for example this
> controller returns immedately:
> def call
>    [200, {'Content-Length' => 2}, ['OK']]
> end
> it also doesnt seem to be eventmachine specific, if i remove the use
> :Eventmachine it also happens.

Hi Chris, this is because the client doesn't know when to stop
reading the connection otherwise, and waits until the keepalive
timeout (5 seconds or so by default).

"Content-Length" (or "Transfer-Encoding") is required by the Rack spec,
so you need to include it in your app (or use
Rack::ContentLength and/or Rack::Chunked middlewares).

Starting with Rainbows! 0.97.0, you can set "keepalive_timeout 0" in
your Rainbows! config block to disable keepalive across all concurrency
models, which lets you violate the Rack spec and get immediate

Eric Wong

More information about the rainbows-talk mailing list