Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#6638 closed bug (invalid)

$.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:


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/

Change History (7)

comment:1 Changed 12 years ago by dmethvin

Keywords: needsreview added
Priority: undecided

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

comment:2 Changed 12 years ago by Rick Waldron

This needs to be reverified with the new ajax module.

comment:3 Changed 12 years ago by ajpiano

Keywords: ajaxrewrite added

comment:4 Changed 12 years ago by Rick Waldron

Keywords: needsreview ajaxrewriteneedsreview,ajaxrewrite

comment:5 Changed 12 years ago by snover

Keywords: needsreview,ajaxrewriteneedsreview ajaxrewrite

comment:6 Changed 12 years ago by jaubourg

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.

comment:7 Changed 12 years ago by dmethvin

Keywords: needsreview ajaxrewrite removed
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.

Note: See TracTickets for help on using tickets.