Hi, I've never posted here before so please forgive me if I'm not observing proper decorum, yadda yadda yadda :-)
I've ran into a very, very strange bug with Prototype I wanted to share and see if anyone else has seen this. In a few of my projects involving Ext JS, I'm using the TreePanel control, which uses AJAX to load child nodes asynchronously. Because I bundle in the prototype library with my Ext, these AJAX calls are being processed by Prototype (v 1.6.0.2). In every instance where I use one of these tree panels, I've noticed the weirdest problem where every so often, totally at random, even though the child nodes are sent back correctly by the server, the tree panel logs an error and the children fail to load. I've been tracking this for weeks now and finally stumbled upon the root cause of the problem, and it turns out to be an apparent bug in Prototype, not in Ext: In the Ajax.Request class, the respondToReadyState method, you have: respondToReadyState: function(readyState) { var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); etc etc etc... Maybe 90% of the time, readyState here and transport.readyState are the same (as they always should be?). However, it turns out, maybe 10% of the time the readyState passed into the event handler is completely different from the ready state in the XHR object (transport.readyState). I set up a piece of code to log this in Firebug (but this happens in every browser, mind you): respondToReadyState: function(readyState) { if (readyState != this.transport.readyState) console.log("readyState is " + readyState + " but transport says " + this.transport.readyState + "!!!!!"); And, in the course of perhaps 15 minutes of various ajax requests (not just in my tree panel, but anywhere), I see this in my console: readyState is 170 but transport says 1!!!!! readyState is 7 but transport says 1!!!!! readyState is 7 but transport says 1!!!!! readyState is 3 but transport says 1!!!!! readyState is 4 but transport says 1!!!!! That last one is the real problem - because readyState is 4 but the real readyState in the XHR object is still actually 1, the success callback is triggered (because Ajax.Response checks transport.readyState, not the readyState passed to respondToReadyState), but there is no responseText (yet), so the whole call fails. Extremely frustrating bug to tease out, let me tell you, because Firebug *always* seems to get the right responseText, even though Prototype doesn't. It was easy enough now to fix my problem, all I did was this: respondToReadyState: function(readyState) { readyState = this.transport.readyState; [ continue on as normal ] And now I have *no* problems. But I really don't like the idea of modifying my prototype :-(. So what gives? Can I really be the only person this is happening to? And what the heck would a readyState of 170 mean anyway? It's super-duper-done? Thanks for listening, and despite this little glitch, thanks so much for Prototype! I just can't live without my Enumerables! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---