Skip to main content

Bug Tracker

Side navigation

#6638 closed bug (invalid)

Opened June 06, 2010 02:11AM UTC

Closed April 01, 2011 01:10PM UTC

Last modified March 13, 2012 07:45PM UTC

$.ajax complete function is not fired if success / error functions throw errors

Reported by: snover Owned by:
Priority: undecided Milestone:
Component: ajax Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

Once an ajax request has completed, if an error is thrown from the success or error functions, the complete function does not fire. I am not sure if this is intended behaviour or not, but it would seem to me that there is no real reason not to ensure complete is dispatched too.

Additionally, in Firefox (tested in 3.5.9 with Firebug 1.4.5 and 3.6.3 with Firebug 1.5.4), these uncaught errors are silently discarded, which makes debugging kinda hard. Chrome and Safari display the errors properly.

Testcase: http://jsfiddle.net/uqucB/1/

Attachments (0)
Change History (7)

Changed November 15, 2010 03:17AM UTC by dmethvin comment:1

keywords: → needsreview
priority: → undecided

Silently discarding the errors is the painful part here. I wonder if we can catch/rethrow them?

Changed December 27, 2010 08:46PM UTC by rwaldron comment:2

This needs to be reverified with the new ajax module.

Changed December 27, 2010 09:07PM UTC by ajpiano comment:3

keywords: needsreviewneedsreview ajaxrewrite

Changed December 27, 2010 10:37PM UTC by rwaldron comment:4

keywords: needsreview ajaxrewriteneedsreview,ajaxrewrite

Changed December 27, 2010 10:40PM UTC by snover comment:5

keywords: needsreview,ajaxrewriteneedsreview ajaxrewrite

Changed January 09, 2011 05:42AM UTC by jaubourg comment:6

The behaviour is the same in the rewrite. It seems preferable to end execution and have the exception make its way directly to the user. Any finally or rethrow block will obfuscate the exception in most browsers which makes debugging a real nightmare.

Changed April 01, 2011 01:10PM UTC by dmethvin comment:7

keywords: needsreview ajaxrewrite
resolution: → invalid
status: newclosed

If you know the handler can throw an error in some cases, wrap it in a try/catch. As jaubourg says, having us do that makes it very difficult for users to debug their problems.