Search code examples
javascriptpromisebluebirdrxjs

How do I get rid of a Bluebird warning when chaining more than one flatMap operator in RxJS?


This code gives me this error

Warning: a promise was created in a handler but none were returned from it

var Observable = Rx.Observable;

var source = Observable.range(0, 3);

source
  .flatMap(item => {
    console.log('getting first promise');
    return Observable.fromPromise(
      new Promise((resolve, reject) => {
        resolve(5)
      })
    );
  })
  .flatMap(item => {
    console.log('item ==', item);
    console.log('getting second promise');
    return Observable.fromPromise(
      new Promise((resolve, reject) => {
        resolve(4)
      })
    );

  })
  .subscribe(x => console.log('sub1 == ', x));

If I remove the second flatMap operator, I don't get the error. Why is the the second RxJS flatMap operator causing a Bluebird warning, but the first flatMap isn't? And, of course, what do I need to fix in how I'm using Bluebird Promises?

Here's a Plunk that demonstrates the issue, you'll see the warnings in Chrome's Developer Console


Solution

  • Can't tell but that message is from bluebird, not from Rxjs. You can have a look here : https://github.com/petkaantonov/bluebird/issues/854. It seems to be your exact same issue which is dealt with there.