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

Promise.map(), Promise.filter(), etc. return native Promises instead of Bluebird #72

Open
MadaraUchiha opened this issue May 10, 2017 · 10 comments

Comments

@MadaraUchiha
Copy link
Collaborator

#goodnessSquad

@benjamingr
Copy link
Owner

k

@MadaraUchiha
Copy link
Collaborator Author

What you did won't do. As long as an async function returns a native Promise, you need to wrap the whole thing with return Bluebird.resolve((async () => {})());

@itaysabato
Copy link

Hey there :)

This project looks very promising - nice work! I have a couple of questions, if you may:

  1. When this issue is resolved, async functions will return the bluebird-api version of native promises?
  2. If so, will it be possible to use the bluebird cancel() API in conjunction with async functions?

Thanks!

@MadaraUchiha
Copy link
Collaborator Author

No to both. Sadly, as it currently stands, async functions always return native promises, that's why there's a return Bluebird.resolve() around every function implementation.

@itaysabato
Copy link

itaysabato commented Aug 5, 2017

I see.
So there is actually no practical way to use cancellations with native async functions in node?

It would have been really nice if there was a way to monkeypatch native promises to support these kinds of things that will probably never make it to ECMAScript...

@benjamingr
Copy link
Owner

There was a proposal that allowed this - it was rejected (compositional functions)

There was another proposal that allowed this (cancellable promise) which was also rejected.

Sorry - the good people of th TC don't like these proposals very much - and the sad truth is that there is politics involved.

On the other hand, you can manually use tokens

@itaysabato
Copy link

I don't care very much for tokens - I started using them when I thought the proposal will be accepted but once it was dropped I decided to go back to bluebird-style cancel which is a much better approach in my eyes.

The question is: is it possible that node will ever provide its own hooks for extending promises, regardless of the ECMAScript standard? It seems like a pretty simple then interceptor would enable one to implement custom cancellations.

@benjamingr
Copy link
Owner

@itsysabato - we can discuss this at Node - if you have a concrete proposal.

However, I have to say chances are pretty slim.

@itaysabato
Copy link

@benjamingr OK then.
Thanks a lot anyway!

@benjamingr
Copy link
Owner

@itaysabato sure, and sorry for losing :)

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

No branches or pull requests

3 participants