Is there way to determine if there are any unsolved promises, deferreds or callbacks in jQuery? We have a large single-page JavaScript application that is hanging on $(document).ready(). For debugging purposes we would like to see if we missed calling a callback or resolving a promise or deferred to see if that might be affecting .ready().
Asked
Active
Viewed 46 times
-1
-
I thought you manage your own deferred, promises and callbacks? So you should have known what are unresolved/called. – King King Apr 06 '17 at 15:30
-
That's does not answer the question! – A2MetalCore Apr 06 '17 at 15:31
-
I questioned you back because your question is not very clear. Please improve it as soon as possible. – King King Apr 06 '17 at 15:32
-
I thought it was pretty clear. But I'll add some more words. – A2MetalCore Apr 06 '17 at 15:33
-
For someone who doesn't know the answer, this (after the edit) is a fair question. – Roamer-1888 Apr 06 '17 at 17:19
1 Answers
1
Two pieces of good news :
- jQuery and Deferreds and Promises both have a
state()
method that returns "pending", "resolved" or "rejected". - Nothing you do with jQuery promises will inhibit firing of the event underlying
$(document).ready()
.
Bad news - you still have an issue that needs fixing.
Without seeing the code (preferably a minimal example that exhibits the issue), it's impossible to say what the cause might be.
First thing to do is look in your browser's console to see if it shows some sort of error.

Roamer-1888
- 19,138
- 5
- 33
- 44
-
Is there a way to enumerate all pending promises system wide? I suspect that there isn't. And, based on #2 above these probably don't have anything to do with .ready() not resolving. – A2MetalCore Apr 06 '17 at 20:17
-
1No, there's no natural way to find all pending deferreds/promises. They are just javascript objects much like any other. The only way to know they exist is to keep a reference (ie by assignment). That's viable for deferreds/promises you create yourself (which should be rare) but not always possible for deferreds/promises created in 3rd-party code unless you are prepared to modify it. – Roamer-1888 Apr 06 '17 at 23:10