-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bluebird circular promise error while q-promise works #682
Comments
This is because pouchDb resolves with itself which normally leads to infinite loop. In fact doing this in Q leads to infinite loop while bluebird currently gives the circular error immediately: var o = {
then: function(f) {
setTimeout(function() {
f(o);
}, 1);
}
};
Q(o).then(function(){
// Never happens.
}) The reason pouchDB works in Q is that pouchDB actually does something like this: var o = {
then: function(f) {
setTimeout(function() {
delete o.then;
f(o);
}, 1);
}
};
Q(o).then(function(){
// No problem.
}) So it won't lead to infinite loop because on second iteration there is no It's still a bug because Promises/A+ clearly requires an implementation to go into an infinite loop into the first scenario instead of rejecting with the circular resolution error. |
Yeah, looks like a bug in Promises/A+. Would you mind to report it? |
I think before opening an actual bug at A+ it'd be wise to ping @domenic On Thu, Jul 2, 2015 at 2:05 PM, Bergi notifications@github.com wrote:
|
I meant to reply where I did :-) I don't think discussing this in a promisesaplus issue would have been wrong, even if the bug is invalid. |
The following code uses q-library to wrap PouchDB as a promise
It works fine. But switching to bluebird by changing the first line to
leads to the following error:
the error was thrown at line 20
deferred.resolve(_pouchdb)
.I know
Promise.defer()
is depreciated, usingnew Promise
gets the same error.I also tried to run the code in a browser (Chrome 43), bluebird throws the same error and both q and Chrome's native promise work fine. I'm using bluebird version 2.9.30
The text was updated successfully, but these errors were encountered: