# Safari 3.1 AJAX crashes not caused by getElementsByClassName

**URL:** <https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074>\
**Category:** Rails\
**Created:** [March 27, 2008, 1:54pm UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074 "2008-03-27T13:54:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 27, 2008, 1:54pm UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/1 "2008-03-27T13:54:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 27, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/2 "2008-03-27T14:46:14Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 29, 2008, 12:19am UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/3 "2008-03-29T00:19:11Z")

</div>

Nauhaie N. 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!

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 29, 2008, 4:36pm UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/4 "2008-03-29T16:36:41Z")

</div>

On 28 Mar 2008, at 23:19, A. james Boswell wrote:

> > * * *
> > 
> > * * *
> > 
> > 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

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 29, 2008, 11:41pm UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/5 "2008-03-29T23:41:19Z")

</div>

Frederick C. wrote:

> On 28 Mar 2008, at 23:19, A. james Boswell wrote:
> 
> > > 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.

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?

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 30, 2008, 11:17am UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/6 "2008-03-30T11:17:50Z")

</div>

Frederick C. 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 🙂

Cheers

AJB

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 30, 2008, 11:25am UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/7 "2008-03-30T11:25:03Z")

</div>

A. james Boswell wrote:

> Thanks so much Fred!  
> just what I needed to know 🙂

Dang! Spoke too soon

Freezing to the gems for Rails 2.0.2  
Unpacked gem:  
‘/home/familie2/registration/vendor/rails/activesupport-2.0.2’  
ERROR: While executing gem … (Gem::Exception)  
Cannot load gem at  
[/home/familie2/.gems/cache/activerecord-2.0.2.gem] in  
/home/familie2/registration/vendor/rails

Do I need to clobber the cache somehow?

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [March 30, 2008, 11:12am UTC](https://www.ruby-forum.com/t/safari-3-1-ajax-crashes-not-caused-by-getelementsbyclassname/133074/8 "2008-03-30T11:12:09Z")

</div>

On Mar 29, 11:41 pm, “A. james Boswell” \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> Frederick C. 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
