Bug Tracker

Opened 13 years ago

Closed 12 years ago

#7569 closed bug (invalid)

ready event #2 does not fire when ready event #1 fails with exception

Reported by: elygre Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:


In a scenario with multiple ready events, as soon as one of them fails, jQuery stops executing the others.

For an example, see http://jsfiddle.net/elygre/ATCN9/2/, which displays only the first alert, and never the second:

$(function() { alert('Ready #1'); window.FailBigTime(); });
$(function() { alert('Ready #2'); });

In our portal, we use jQuery as a base framework. Users are able to insert portlets, and if they make mistakes in their portlets, the entire portal becomes unstable, as other portlets and the portal itself suddenly cease to initialize properly.

The expected behaviour (I would think) is for jQuery to wrap execution of every registered ready-function in a try/catch-clause, and continue with the next one.

Change History (3)

comment:1 Changed 13 years ago by dmethvin

Keywords: needsreview added

I understand the dilemma, you're trying to run unreliable code and want it to do the least damage possible. However, what should jQuery do with the error generated? Discard it? That would make debugging difficult. All of the browser's debuggers generate error messages with specific problems and line numbers for this case, and much of that is lost when the function is wrapped in a try/catch.

comment:2 Changed 13 years ago by mrgnrdrck

Libraries should not have surprising behaviour.

jQuery eating up exceptions (or rethrowing them asyncronously) during initialiasation would be surprising and incovenient to most users.

A higher level framework might be expected to have unbreakable initialisation of "portlets", but for a library meant for evening out the playing field of browsers and work with DOM, this would be a mistake.

comment:3 Changed 12 years ago by dmethvin

Keywords: needsreview removed
Resolution: invalid
Status: newclosed

I'd suggest that you replace the .ready() method to add your own portal error handling, and have it call the original .ready() method with a new function that wraps a try/catch around the caller's original function. That way you can integrate the error handling and/or reporting into your portal. We can't do that from our perspective.

Note: See TracTickets for help on using tickets.