Reputation: 319
I use mongoose and bluebird as a promise framework. Everytime I use "save" or "remove" I get this error :
Warning: a promise was created in a handler but was not returned from it
I really tried spending on it a few days, while googling, I tried so much ways, to mention some:
Kinda funny but I tried updating all my project npm packages, because I saw talks about it in github and someone mentioned they solved it already. but it didn't work.
And much more.. I'm really desperate.
Don't get me wrong, the code works great, but seeing this HUGE warnings in my console each time makes me feel really guilty.
Any suggestions?
Upvotes: 0
Views: 175
Reputation: 276596
This error means some code did something like:
somePromise.then(x => {
someOtherPromiseReturningFunction();
}).then(value => {
// forgot a return, oh dear
});
Which is a very common mistake of forgetting a return
, it messes with error handling and causes issues.
Sometimes the problem is not with your code but with the code of a library you're using - in that case you should disable warnings for that code:
require("bluebird")
and use it with warnings.You can get two copies of bluebird by using require("bluebird")
in your code and overriding mongoose's Promise with require("bluebird/js/release/promise")();
which creates a standalone copy.
Upvotes: 1