Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

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

Open
cibernox opened this issue Jan 3, 2018 · 1 comment
Open

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

cibernox opened this issue Jan 3, 2018 · 1 comment

Comments

@cibernox
Copy link

cibernox commented Jan 3, 2018

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

@alexlafroscia
Copy link
Collaborator

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants