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

Async remote method always returns null #2

Closed
madeleinedaly opened this issue Mar 26, 2018 · 3 comments
Closed

Async remote method always returns null #2

madeleinedaly opened this issue Mar 26, 2018 · 3 comments

Comments

@madeleinedaly
Copy link
Contributor

I'm trying to follow the instructions in the README for defining a remote method that returns a promise, but my client code (in Emacs) only ever receives null after calling that method. And that null appears to be returned synchronously, before the async task in my remote method actually resolves a real value to return.

I created a failing test case for this issue here: madeleinedaly@525b722

@madeleinedaly madeleinedaly changed the title Async remote methods always return null Async remote method always returns null Mar 26, 2018
@madeleinedaly
Copy link
Contributor Author

madeleinedaly commented Apr 9, 2018

It turns out that returning a native promise from a remote method won't pass the instanceof check here:

if (ret instanceof Promise) {

My test above passes if I return a bluebird promise from the remote method. I wonder if it's worth updating the docs to specify that bluebird must be used? Or we could use something like https://github.com/sindresorhus/p-is-promise instead of instanceof to allow either native or bluebird promises in the caller. I'd be happy to contribute the latter change as a PR.

@kiwanami
Copy link
Owner

Thank you for your nice report. I merged your PR.

Yes. I also think that this project should remove bluebird as a polyfill of ES6 Promise...

@madeleinedaly
Copy link
Contributor Author

Thanks for this set of libraries! It has opened a new world of possibilities for me.

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

2 participants