Your problem is being caused by a missing Content-Length header in the HTTP response:
$ curl -v -d "" http://slowajax.heroku.com/foo * About to connect() to slowajax.heroku.com port 80 (#0) * Trying 75.101.163.44... connected * Connected to slowajax.heroku.com (75.101.163.44) port 80 (#0) > POST /foo HTTP/1.1 > User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 > OpenSSL/0.9.8l zlib/1.2.3 > Host: slowajax.heroku.com > Accept: */* > Content-Length: 0 > Content-Type: application/x-www-form-urlencoded > < HTTP/1.1 201 Created < Server: nginx/0.6.39 < Date: Wed, 29 Sep 2010 22:44:32 GMT < Content-Type: application/json; charset=utf-8 < Connection: keep-alive < X-UA-Compatible: IE=Edge,chrome=1 < X-Runtime: 0.231929 < Cache-Control: no-cache * no chunk, no close, no size. Assume close to signal end < * Closing connection #0 {"foo":"bar"} The controller in the test app requested above is as follows: class FooController < ApplicationController def create render :json => {'foo' => 'bar'}.to_json, :status => :created end end Manually setting the Content-Length header fixed the problem. I assume that this is a bug in thin. class FooController < ApplicationController def create body = {'foo' => 'bar'}.to_json response.headers['Content-Length'] = body.length.to_s render :json => body, :status => :created end end Jake On Sep 14, 12:58 pm, Guillaume Fradin <guillaumefra...@googlemail.com> wrote: > Have you been able to solve this issue? > > I ran into the same problem and support has not been able to help. > > After quite some trial and error, I realised the problem only occured > when the response contained a status :created > so only in my create methods. > > I could then replace them from: > > respond_with(@resource) > > to > > if @resource.save > render :json => @resource.to_json # same as in Responder, simply > short of the :created status > else > respond_with @extract_list # still reponds errors > end > > a bit more verbose, but ok for me. Still I have no idea why > this :created status was making the request > really slow, as if the http was not closing (or something else) > > On Aug 24, 3:27 am, John McCaffrey <john.mccaff...@gmail.com> wrote: > > > > > Sounds like an interesting problem. > > > To recap: > > 1. You do not see this behavior locally in Firefox or Safari, but only when > > deployed to Heroku (and that's why you posted to this group) > > 2. Its always been this way, and nothing changed recently (new version of > > jquery, etc) > > > Is this something that we can test ourselves on a public URL? > > > I could take a look at it using some of the low level tools that work in IE > > (VRTA, fiddler, httpwatch, etc), as well as google speed tracer, which will > > show you a breakdown of the events from dns lookup, request, download, > > parse, render. > > > Is the payload large? Is it possible that it takes forever for it to be > > parsed? > > > Not sure how easy it would be to take a completed response and then mock the > > xhr call to see if taking the network out of the equation displays the same > > problem (mocking the xhr states might be something that's already covered in > > any of the javascript testing frameworks) > > > I've been evaluating a few of the browser tools, and would welcome a good > > use case to test them against, and see which one helps identify the problem, > > so go ahead and give us the url so we can try it out and give you a hand > > with this. (I know how frustrating a problem like this can be) > > > -John > > > On Fri, Aug 20, 2010 at 7:14 PM, Donald Ball <donald.b...@gmail.com> wrote: > > > For what it's worth, I've now tried logging the AJAX with both firebug > > > and firebug-lite. Firebug reports the AJAX HTTP response as received > > > within tens of milliseconds, while firebug-lite reports it as received > > > after 4-5 seconds. This suggests to me that the lag is occurring in > > > the browser; maybe the HTTP connection isn't being closed promptly on > > > heroku's side of things? > > > > - donald > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Heroku" group. > > > To post to this group, send email to her...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > heroku+unsubscr...@googlegroups.com<heroku%2bunsubscr...@googlegroups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/heroku?hl=en. > > > -- > > -John -- You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to her...@googlegroups.com. To unsubscribe from this group, send email to heroku+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/heroku?hl=en.