Skip to main content

Bug Tracker

Side navigation

#11193 closed bug (duplicate)

Opened January 19, 2012 11:05AM UTC

Closed January 19, 2012 02:45PM UTC

Last modified April 02, 2014 01:26AM UTC

jQuery.Callbacks left in inconsistent state after exception

Reported by: arnaud.lb@gmail.com Owned by: arnaud.lb@gmail.com
Priority: low Milestone: None
Component: event Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

If an exception occurs in a callback, the jQuery.Callback instance is left in an inconsistent state; as a result fire() and add() won't call anything after that, because 'firing' is true.

It seems that exceptions could be caught and re-thrown after firing has been set to false.

Attachments (0)
Change History (8)

Changed January 19, 2012 11:47AM UTC by addyosmani comment:1

component: unfiledevent
owner: → arnaud.lb@gmail.com
priority: undecidedlow
status: newpending

Thanks for submitting a ticket to the jQuery bug tracker. Could you please include a test case on jsfiddle.net that reproduces the issue you're experiencing with $.Callbacks?

Changed January 19, 2012 12:09PM UTC by anonymous comment:2

Sure, here is the jsfiddle: http://jsfiddle.net/2G23g/2/

Changed January 19, 2012 02:45PM UTC by jaubourg comment:3

resolution: → duplicate
status: pendingclosed

It's not really a duplicate of #9033 per se, but all the info and discussion are there: Callbacks and Deferred objects are locked because:

1. Catching rethrowing makes debugging impossible in IE

2. try/finally is not supported in all IE

3. the error should be notified and as vocal as possible (you do want the exception to halt the program somehow in order to be able to debug).

4. If you want to treat the exception, do it in the callback itself (basic locality principle).

Changed January 19, 2012 02:46PM UTC by jaubourg comment:4

Duplicate of #9033.

Changed November 12, 2012 02:48PM UTC by dmethvin comment:5

#12884 is a duplicate of this ticket.

Changed July 29, 2013 07:07PM UTC by dmethvin comment:6

#14201 is a duplicate of this ticket.

Changed April 02, 2014 12:05AM UTC by spicyj comment:7

I just ran into this. Any chance we could reopen and fix this for jQuery 2.x? IE8+ supports try/finally properly so there shouldn't be a problem. In React we have a similar wrapper for processing a list of callbacks where we run every callback but make sure the first error bubbles up to aid debugging:

https://github.com/facebook/react/blob/master/src/utils/Transaction.js#L230-L260

If it would be helpful I'd be happy to submit a patch to fix this.

Changed April 02, 2014 01:26AM UTC by dmethvin comment:8

Can you open a new ticket and reference this one? We will be dropping IE 6/7 support soon so we could make a case for it now. Thanks!