Questions tagged [bluebird]

Bluebird is a fully featured promise library for client and server JavaScript with focus on innovative features and performance.

Bluebird is a fully featured promise library for client and server JavaScript code with focus on innovative features and performance.

Bluebird is known for its fast performance, context binding, and long stack traces. It offers very fast coroutine support that emulates C#'s async/await statement.

Bluebird's promise system also cures JavaScript's callback problem.

It is a fully A+ spec compliant implementation.

Bluebird supports both Node.js and browsers (with Browserify and directly).

1871 questions
29
votes
3 answers

What is the difference between then and finally in a promise?

I see the docs for Bluebird's finally but I still don't quite understand the difference vs. then. To be clear: I know exactly why then gets called after a catch. I want it to be called after a catch. That's the intent. My question is: If I want code…
Jason C
  • 38,729
  • 14
  • 126
  • 182
29
votes
1 answer

The correct way to bind object to Promise.then() argument

I found out the hard way that one can't simply just pass in a object's function into the Bluebird then. I'm assuming that Bluebird's then is doing some magic and wrapping the passed in function in an anonymous function. So I attached a .bind to the…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
29
votes
3 answers

Chaining promises with then and catch

I'm using the bluebird Promise library. I'd like to chain promises and catch specific promises errors. Here's what I'm doing : getSession(sessionId) .catch(function (err) { next(new Error('session not found')); }) .then(function (session)…
Alexandre Kirszenberg
  • 35,938
  • 10
  • 88
  • 72
25
votes
1 answer

Can I override ES6's Promise by bluebird's implementation in node's global scope?

I want to use bluebird's implementation of the Promise/A+ open standard and override native ES6 Promises. I also want the bluebird implementation to be available everywhere in my subsequently imported modules without having to require it in every…
Christophe Marois
  • 6,471
  • 1
  • 30
  • 32
25
votes
5 answers

How can I promisify the MongoDB native Javascript driver using bluebird?

I'd like to use the MongoDB native JS driver with bluebird promises. How can I use Promise.promisifyAll() on this library?
Dmitry Minkovsky
  • 36,185
  • 26
  • 116
  • 160
24
votes
1 answer

What does compound let/const assignment mean?

There is an article Optimization killers in wiki of Bluebird library. In this article there is a phrase: Currently not optimizable: ... Functions that contain a compound let assignment Functions that contain a compound const…
Alexander Myshov
  • 2,881
  • 2
  • 20
  • 31
23
votes
5 answers

Parallel operations with Promise.all?

I'm led to believe that Promise.all executes all the functions you pass it in parallel and doesn't care what order the returned promises finish. But when I write this test code: function Promise1(){ return new Promise(function(resolve,…
Steve
  • 576
  • 2
  • 7
  • 21
22
votes
4 answers

Testing rejected promise in Mocha/Chai

I have a class that rejects a promise: Sync.prototype.doCall = function(verb, method, data) { var self = this; self.client = P.promisifyAll(new Client()); var res = this.queue.then(function() { return self.client.callAsync(verb, method,…
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
22
votes
2 answers

Trigger Promise when an event fires

My entire project uses (Bluebird) Promises, but there's one particular library that uses EventEmitter. I want to achieve something like: Promise.on('connect', function() { x.doSomething(); }).then(function() { return new…
Jaydeep Solanki
  • 2,895
  • 5
  • 36
  • 50
21
votes
2 answers

Stop running processes after a Promise is rejected

I'm using the following code which working OK, but the problem is that when I get an error, I want it to stops all the other promises. For example if chi.getCommand(val1, val2), will send a reject and I got to the exception catch, I want to cancel…
user4209821
21
votes
3 answers

Bluebird warning "A promise was created in a handler but was not returned from it"

I get the warning about not returning a created promise from Bluebird and I do not understand why and how I should rewrite my code. (I have tried reading about the warning at Bluebird API page and the anti-pattern page as I suspect this is what I'm…
21
votes
3 answers

Slowdown due to non-parallel awaiting of promises in async generators

I'm writing code using generators and Bluebird and I have the following: var async = Promise.coroutine; function Client(request){ this.request = request; } Client.prototype.fetchCommentData = async(function* (user){ var country = yield…
Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504
20
votes
2 answers

bluebird.js vs bluebird.core.js what is the difference?

What is the difference between bluebird.js and bluebird.core.js? When should I use bluebird.core.js instead of bluebird.js? I haven't been able to find anything in the bluebird site or elsewhere.
Jeremy Danyow
  • 26,470
  • 12
  • 87
  • 133
20
votes
2 answers

How to cast jQuery $.ajax calls to Bluebird promises without the deferred anit-pattern

Right now I use promise.deferred in a core file. This allows me to resolve promises at a central location. I've been reading that I may be using an anti-pattern and I want to understand why it is bad. so in my core.js file I have functions like…
Jeff
  • 2,293
  • 4
  • 26
  • 43
19
votes
1 answer

EventEmitter in the middle of a chain of Promises

I am doing something that involves running a sequence of child_process.spawn() in order (to do some setup, then run the actual meaty command that the caller is interested in, then do some cleanup). Something like: doAllTheThings() …
d11wtq
  • 34,788
  • 19
  • 120
  • 195