Bug Tracker

Ticket #6638 (closed bug: invalid)

Opened 4 years ago

Last modified 3 years ago

$.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:
Blocking: Blocked by:

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/

Change History

comment:1 Changed 4 years ago by dmethvin

  • Keywords needsreview added
  • Priority set to undecided

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

comment:2 Changed 4 years ago by rwaldron

This needs to be reverified with the new ajax module.

comment:3 Changed 4 years ago by ajpiano

  • Keywords ajaxrewrite added

comment:4 Changed 4 years ago by rwaldron

  • Keywords needsreview,ajaxrewrite added; needsreview ajaxrewrite removed

comment:5 Changed 4 years ago by snover

  • Keywords needsreview ajaxrewrite added; needsreview,ajaxrewrite removed

comment:6 Changed 4 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 3 years ago by dmethvin

  • Keywords needsreview ajaxrewrite removed
  • Status changed from new to closed
  • Resolution set to invalid

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.