Safari 3.1 AJAX crashes not caused by getElementsByClassName

Hi all,

I've been having a lot of trouble with Rails Errors for over I week, and
I finally realized that they are caused by Safari 3.1, since everything
works fine with FireFox... Pretty much every AJAX request makes the fcgi
process crash...

Moreover, I do *not* use getElementsByClassName (which is known to be
the cause of many problems), rails is up to date, and so is Prototype
(1.6.0.1).

Here is what the log says:

/!\ FAILSAFE /!\ Thu Mar 27 13:47:50 +0100 2008
  Status: 500 Internal Server Error
  can't modify frozen string
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/request.rb:462:in
`gsub!'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/request.rb:462:in
`clean_up_ajax_request_body!'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/request.rb:380:in
`parse_formatted_request_parameters'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:78:in
`request_parameters'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/request.rb:287:in
`parameters'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/request.rb:22:in
`request_method'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/request.rb:35:in
`method'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/routing.rb:1483:in
`extract_request_environment'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/routing.rb:1424:in
`recognize'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:170:in
`handle_request'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in
`dispatch'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in
`dispatch_cgi'
    /hsphere/local/home/cukch/rails/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in
`dispatch'
    dispatch.cgi:10

I have no idea what this is caused by. The solution that was recommended
is switching to Mongrel, and of course I would do it if I could... But I
am on a shared host, so it is not possible...

Does anyone has any idea how to solve this? I have tried for over a
week, and nothing helps. I tried switching from fastcgi to plain old
cgi, but the bugs remain the same (but plain old cgi is indeed used, for
the request take a lot longer).

Thank you very much if you can help!

Nauhaie

I tried replacing
vendor/rails/actionpack/lib/action_controller/request.rb:462

Nauhaie None wrote:

I tried replacing
vendor/rails/actionpack/lib/action_controller/request.rb:462

---------
  def clean_up_ajax_request_body!(body)
    body.chop! if body[-1] == 0
                body.gsub!(/&_=$/, '')
   end
---------

BY

---------
   def clean_up_ajax_request_body!(body)
  unless body.frozen?
    body.chop! if body[-1] == 0
                body.gsub!(/&_=$/, '')
  end
   end
---------

I don't know if this might cause other kinds of problems, but at least,
it doesn't crash anymore...

Unfortunately I am in shared hosting, can't change fast-cgi to mongrel
and can't hack request.rb.

Looks like I'm snookered until Safari/Fast-CGI/ or rails patches the
bug.

Can anyone think of any other way to work around this? It basically
rules out AJAX from RoR for me which is a major blow!

Nauhaie None wrote:

I tried replacing
vendor/rails/actionpack/lib/action_controller/request.rb:462

---------
def clean_up_ajax_request_body!(body)
   body.chop! if body[-1] == 0
               body.gsub!(/&_=$/, '')
  end
---------

BY

---------
  def clean_up_ajax_request_body!(body)
unless body.frozen?
   body.chop! if body[-1] == 0
               body.gsub!(/&_=$/, '')
end
  end
---------

I don't know if this might cause other kinds of problems, but at
least,
it doesn't crash anymore...

Unfortunately I am in shared hosting, can't change fast-cgi to mongrel
and can't hack request.rb.

You can if you freeze rails into your vendor/rails . IIRC this here is
to work around a bug in some versions of safari where extra stuff
would get appended to the end of ajax requests.

Fred

Frederick Cheung wrote:

Frederick Cheung wrote:
Thanks Fred,
So I'm guessing this means cp'ing from the /usr/lib/ tree through to
either my own project or my own gems path. Is this a manual process is
there some rails scripted way to freeze?

Also - if I set my GEMS path correctly, can I move only the relevant
files across?

There's a rake task: rake rails:freeze:gems
It's an all or nothing thing, you can't just freeze some gems or some
files

Fred

Frederick Cheung wrote:

There's a rake task: rake rails:freeze:gems
It's an all or nothing thing, you can't just freeze some gems or some
files

Fred

Thanks so much Fred!
just what I needed to know :slight_smile:

Cheers

AJB