Skip to content

Returning Result<Vec<u8>, JsError> from an async function doesn't work #3155

@nasso

Description

@nasso

Describe the Bug

The following compiles:

#[wasm_bindgen]
pub fn foo() -> Result<Vec<u8>, js_sys::Error> {
  unimplemented!()
}

While the following does not:

#[wasm_bindgen]
pub async fn foo() -> Result<Vec<u8>, js_sys::Error> {
  unimplemented!()
}

Steps to Reproduce

  1. Copy and paste the second snippet above
  2. cargo check
  3. See error

Expected Behavior

Whatever works without async works the same with async.

Actual Behavior

Sometimes, it does not 😔.

Additional Context

Not the first instance of this issue (see #3059).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions