Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#5688 closed bug (fixed)

Too much recursion errors

Reported by: ixpleo Owned by:
Priority: major Milestone: 1.4
Component: event Version: 1.4a2
Keywords: Cc:
Blocked by: Blocking:

Description

When dropping 1.4a2 into a live application, I get "too much recursion" errors showing up in the Firefox console. This also occured with 1.4a1. I've attached a patch the needs review. Details below.

The original error is reported on Line 1486, but replacing the isFunction() call with !toString.call(proxy) === "[object Function]" fixes this.

The error then moves to Line 1801 - another isFunction() call fixed the same way as above.

The error finally moves to Line 1807: var handler = name == "one" ? jQuery.event.proxy( fn, function( event ) {

The isFunction() function doesn't seem to be the original problem, but rather the call to this.one(). I'm not familiar enough with jQuery core to say for sure, but it looks like this is leading to jQuery.each("one"...) recursion. Remove the call to this.one() fixed the issue for em.

I have attached a patch that fixes the "too much recursion" bug for me - but I am not sure what the implications are of this fix. It definitely needs review by someone who is more familiar with jQuery core than I am.

Attachments (1)

too_much_recursion.patch (469 bytes) - added by ixpleo 13 years ago.
Patch for "too much recursion" error.

Download all attachments as: .zip

Change History (10)

Changed 13 years ago by ixpleo

Attachment: too_much_recursion.patch added

Patch for "too much recursion" error.

comment:1 Changed 13 years ago by dmethvin

Can you provide a test case? We need to know the cause of the problem, as well as a solution.

comment:2 Changed 13 years ago by MelTraX

I have the same problem. The error occurs in line 1486 but that doesn't seem to be the problem. The recursion is somewhere else.

It can easily be triggered with "$(window).bind('unload', function() {});". I can't suggest a solution though.

comment:3 Changed 13 years ago by ixpleo

After looking at MelTraX's post and looking at the testing I did to come up with the patch, it seems that it is a call to unload() that creates the recursive loop (either directly to unload() or calling unload via bind() as in MelTraX's example). Here's why:

Line 1811 in 1.4a2:

return type === "unload" ? this.one(type, data, handler, thisObject) : this.each(function() {

jQuery.event.add( this, type, handler, data );

});

My fix was to replace this entire statement with just returning the this.each call. When you call unload, it triggers a call to this.one() on line 1811 which is where the recursion is occurring. Even though my patch removes the portion about "unload", unload() events still work.

Do you need me to upload a test case with a call to unload - or this is description enough?

comment:4 Changed 13 years ago by malsup

I see the same problem when testing the form plugin: http://jquery.malsup.com/test/1.4a2.png

comment:6 Changed 13 years ago by Guiswa

comment:7 Changed 13 years ago by john

Component: coreevent
Resolution: fixed
Status: newclosed
Version: 1.4a11.4a2

comment:8 Changed 13 years ago by john

Version: 1.4a21.4a3

comment:9 Changed 13 years ago by john

Version: 1.4a31.4a2
Note: See TracTickets for help on using tickets.