ember-ajax icon indicating copy to clipboard operation
ember-ajax copied to clipboard

Using the ajax `$.active` does not decrement with 422 responses

Open cibernox opened this issue 8 years ago • 1 comments

$.active is a well-known trick to discover how many pending ajax request there is on a page. Most commonly used in testing.

It turns out that refactoring a $.ajax into this.get('ajax').request broke my tests because when an 422 response is received, a InvalidError is thrown from the jqXHR.done callback, preventing the normal behavior of $.active

Background about the bug in jQuery: https://bugs.jquery.com/ticket/11207

I believe that moving from done/fail to a wrapped promise + then/catch might fix the issue, but I haven't had time to check it. I leave my thoughts here and I'll try to investigate it further another day.

cibernox avatar Jan 03 '18 19:01 cibernox

Is there a reason your tests are relying on $.active? If the issue is needing to "wait" until your requests are finished, that should "just work" based on some of the compatibility code we have in the addon.

alexlafroscia avatar Mar 26 '18 17:03 alexlafroscia