Skip to content
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

When using .return on a thenable, the .then function gets called too early #1210

Closed
not-an-aardvark opened this issue Aug 25, 2016 · 0 comments

Comments

@not-an-aardvark
Copy link
Contributor

not-an-aardvark commented Aug 25, 2016

Please answer the questions the best you can:

  1. What version of bluebird is the issue happening on?

3.4.3

  1. What platform and version? (For example Node.js 0.12 or Google Chrome 32)

Node.js v6.4.0

  1. Did this issue happen with earlier version of bluebird?

No; this only happens since v3.4.2.


Reproduction code:

var Promise = require('bluebird');

var myObject = {
  then: function() { console.log('.then was called'); }
};

var promiseForMyObject = Promise.delay(5000).then(function() {
  // myObject happens to have a .then function, but we don't actually want it to be treated as a thenable.
  // As a workaround, just get rid of the .then function.
  myObject.then = undefined;
}).return(myObject)
  .then(function() {
    console.log('promiseForMyObject fulfilled');
  });

Output in <= v3.4.1:

(after 5 seconds): promiseForMyObject fulfilled

Output in v3.4.2 and v3.4.3:

(immediately): .then was called
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@petkaantonov @not-an-aardvark and others