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

4.0.1 causes problems with Bluebird #426

Closed
tprobinson opened this issue May 21, 2020 · 5 comments · Fixed by #427
Closed

4.0.1 causes problems with Bluebird #426

tprobinson opened this issue May 21, 2020 · 5 comments · Fixed by #427
Labels

Comments

@tprobinson
Copy link

I've gotten an error from Bluebird when using execa at version 4.0.1:

TypeError: this._then is not a function
    at Promise.then (~/.config/yarn/global/node_modules/bluebird/js/release/promise.js:154:17)
    at ChildProcess.then (~/.config/yarn/global/node_modules/execa/lib/promise.js:13:25)

This works fine if I downgrade execa to 4.0.0.

@ehmicky ehmicky added the bug label May 21, 2020
@ehmicky
Copy link
Collaborator

ehmicky commented May 21, 2020

Thanks for reporting this problem @tprobinson!

@fisker This appears to be related to #403, do you know what the problem might be?

@fisker
Copy link
Contributor

fisker commented May 22, 2020

I don't know, but I'll take a look.

@fisker
Copy link
Contributor

fisker commented May 22, 2020

I found the reason, here we use Promise.prototype, which is bluebird.protype(global.Promise is override) in this case, and here we use async function returns a native Promise, so we are calling bluebird#then on native Promise.

Old version use Promise#then directly, so there is no problem.

I see possible solutions

  1. use old logic, change it back to
(...args) => promise()[property](...args);
  1. use this to get the nativePromise
const nativePromise = (async () => {})().constructor;
  1. wrap async function to return a global.Promise(bluebird in this case) instance, I think this is bad idea.

Which one do you prefer?

@ehmicky
Copy link
Collaborator

ehmicky commented May 22, 2020

I think 1. might be simpler. 2. is a little more involved, but it works too.

@fisker
Copy link
Contributor

fisker commented May 22, 2020

I think 2 better, some old Promise lib may don't have .finally, or broken like I did in the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants