Lot of promises remain unresolved
See original GitHub issueI’m using deferred.monitor() to monitor all the promises that are still unresolved after 20 seconds the end of the program
This is the code:
deferred.monitor();
deferred.monitor(20000, function (err) {
console.log('PROMISE',err.stack)
});
The problem is that a lot of promises remain unresolved, but they shoudn’t (the line def.resolve is executed).
Someone of them rejects an error, but in this case they should be considered as resolved, shoudn’t they?
May be there some causes of this behaviour?
PS: hoping this is the reight place where I can talk about this topic
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Finding unresolved promises in JavaScript | Swizec Teller
Finding unresolved promises is an instance of the halting problem – a provably unsolvable problem. There is no algorithm you can write that...
Read more >Process exits with unresolved promises · Issue #16 - GitHub
A lot of users struggle understanding why a Node.js process exits while a promise is still running not yet resolved (see e.g., ...
Read more >Creating a (ES6) promise without starting to resolve it
Good question! The resolver passed to the promise constructor intentionally runs synchronous in order to support this use case:
Read more >Debug Tips - finding an unresolved promise using console.log
Sometimes as a beginner you might code a while loop or a for loop and accidentally create an infinite loop, or maybe you...
Read more >How can I check if there are any unresolved promises ... - Reddit
But if I happen to have accidentally have an outstanding promise still running at the end of my test, that is not detected....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@anjil all is as expected, and there’s no issue. See it’s “Initialized as Unresolved”, not “Never resolved”. It’s those that never resolve that signal an issue.
All promises created with
deferred()and then resolved with eitherdeferred.resolveanddeferred.rejectare understood as “Unresolved at initialization”.To have promise resolved at initialization, you would have to create resolved promise right away via e.g.
deferred('foo'), which will create promise that’s already resolved with foo value.I used the same code shared in the documentation and even that give 2 unresolved promises. The sample is as below:
Output is:
Please let me know what’s the issue.