Skip to main content

Bug Tracker

Side navigation

#7569 closed bug (invalid)

Opened November 19, 2010 11:49AM UTC

Closed December 23, 2010 06:16PM UTC

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:
Description

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.

Attachments (0)
Change History (3)

Changed November 19, 2010 01:38PM UTC by dmethvin comment:1

keywords: → needsreview

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.

Changed December 03, 2010 09:48PM UTC by mrgnrdrck comment:2

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.

Changed December 23, 2010 06:16PM UTC by dmethvin comment:3

keywords: needsreview
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.