Friday, February 09, 2007

Prototype 1.5 bug?, at least not backward compatible with auth_generator...

Hi,

I recently upgraded my web app to Rails 1.2 coming along with Prototype 1.5. Also, In that app, I'm using the auth_generator plugin, a wonderfull plugin allowing to create a user base + login system + right policy in a snap. But what makes it very special is that this Rails plugin can display users info in a javascript generated DOM fragment that will behave accordingly to the user specific cookie allowing you to cache all your pages statically, and that's really a big win considering how slow ruby is compared to hitting only Apache for static pages.

Ok, but this is not the point. The point is that auth_generator has got some simple Ajax requests and they do not work anymore with Prototype 1.5 at least with Firefox (2.0.0.1 on Ubuntu Linux Edgy)!
Here is an example of such a request:
new Ajax.Updater('accountinfo', 'http://localhost:3000/auth/logout', {asynchronous:true, evalScripts:true, onLoading:function(request){Element.show('ident_spinner')}}); return false;")
Nothing especiall as you can see (Or please tell me if I'm wrong).
But this freezes on a Prototype exception arround the line 916:

[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.setRequestHeader]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://localhost:3000/javascripts/prototype.js?1170853340 :: anonymous :: line 916" data: no]


I have no idea at all what should be the correct behavior, if that's a Prototype bug, a Firefox bug or an auth_generator bug.

I have no idea of what side effect this could have, but a dummy fix for me consisted in rewritting the lines arround line 916 this way:

for (var name in headers) {
try {
this.transport.setRequestHeader(name, headers[name]);
} catch (e) {
//do nothing
}
}


Hope this helps, if you have a better fix, please go on and comment.

Raphaël

Update: OK, Prototype 1.5 really bombs out with Firefox, others railers discovered the bug and they found no other fix, see here:
http://dev.rubyonrails.org/ticket/6918

5 comments:

Joan said...

Hi! I had got the same problem!
I've applied your solution and now my page runs perfect. Thank you!

Anonymous said...

Hello. And Bye.

Anonymous said...

good morning fellas. I'm actually into shoes and I was digging as far as something that singular make. The prices as regards the shoes are all over 350 pounds on every site. But definitively I set this locate selling them for half price. I in reality like those [url=http://www.shoesempire.com]gucci sneakers[/url]. I will probably order those. what is your opinion?

Anonymous said...

hi everyone. I'm honestly into shoes and I have been digging for that singular model. The prices seeking the boots are about 320 pounds on every page. But completely I bring about this location selling them for half price. I really like these [url=http://www.shoesempire.com]gucci sneakers[/url]. I will absolutely buy those. what can you say about it?

Anonymous said...

good morning everyone. I'm honestly into shoes and I have been digging as far as something that particular make. The prices as regards the velcros are approximately 330 bucks on every page. But completely I found this location selling them for the benefit of half price. I in reality like those [url=http://www.shoesempire.com]gucci sneakers[/url]. I will probably buy those. what can you say about it?