Skip to content

rust: accept fallible futures in async_support::spawn #1204

Open
@dicej

Description

@dicej

Currently, async_support::spawn accepts an impl Future<Output = ()>, but it should probably take something like impl Future<Output = anyhow::Result<()>> instead, since the most common cases for spawned Futures involve fallible I/O, and forcing the application to .unwrap() (and thus trap) on any error is not a great default experience.

In the case where such a Future returns an error, we can convert it to a debug string, pass that string to ErrorContext::new, and then close any open streams and/or futures (read or write ends) with that error-context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    asyncRelated to async/streams in the component model.gen-rustRelated to bindings for Rust-compiled-to-WebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions