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

Type parameter P in AsyncWormhole #1

Open
kaimast opened this issue Mar 29, 2021 · 2 comments
Open

Type parameter P in AsyncWormhole #1

kaimast opened this issue Mar 29, 2021 · 2 comments

Comments

@kaimast
Copy link

kaimast commented Mar 29, 2021

(Yay, this seems to be the first issue :) )

I noticed a small issue with the latest version of async-wormhole. When you do not define a pre_post_poll handler for async wormhole it will throw an error like this one:

error[E0698]: type inside `async fn` body must be known in this context
   --> lib/api/src/instance.rs:190:20
    |
190 |         let task = async_wormhole::AsyncWormhole::new(stack, |yielder| -> Result<Box<[crate::Val]>, RuntimeError> {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `P`
    |
note: the type is part of the `async fn` body because of this `await`

The easiest way to fix this is to just set an empty lambda function like so, but that's a little ugly.

task.set_pre_post_poll(|| {});

Maybe we can hide function this method feature flag or require the handler to always be set? I think the error might be super confusing for some users.

@bkolobara
Copy link
Collaborator

(Yay, this seems to be the first issue :) )

Yay 🎉 !! I was always wondering if anyone outside the Lunatic project would use this. Would love to hear about your use case.

When you do not define a pre_post_poll handler for async wormhole it will throw an error like this one:

You are right! This is super bad DX, sorry about that. I was wondering for a long time what an elegant way would be to solve this, but never got around to test different approaches. Ideally it would be a zero-cost operation if you don't set a pre_post function.

A feature flag could be a good solution. If you would like to contribute this, I would be happy to review it.

@kaimast
Copy link
Author

kaimast commented May 3, 2021

(Yay, this seems to be the first issue :) )

Yay tada !! I was always wondering if anyone outside the Lunatic project would use this. Would love to hear about your use case.

Forgot to reply to this 🙄

I was hoping to get async support into wasmer. There's a pull request (that needs some rework) here: wasmerio/wasmer#2219

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