#12 ✓resolved
Comron Sattari

Function#defer leaks memory in FF

Reported by Comron Sattari | April 15th, 2008 @ 01:12 AM | in

After recently upgrading to 1.6 from 1.5, I noticed that while testing my rails app with selenium in FF, many of our tests that depended on Ajax requests were failing intermittently. After a lot of digging around I found that the cause of the failures was the NS_ERROR_NOT_AVAILABLE error in Firefox.

The request does not violate SOP, and it was validated that Prototype does not cause the error. Also, the rails app is responding 200, not 404. After diffing source with I noticed one difference that looked interesting to me.

     if (this.options.asynchronous)
             setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10);


      if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1);

I changed this line to

      if (this.options.asynchronous) this.respondToReadyState.bind(this).delay(0.01, 1);

and my problem went away. Is there any reason why the timeout was removed in favor of running the function immediately?

I've attached a diff that passes all the tests, not sure how to write a test for this specific problem.



Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins


Referenced by