Skip to content

async / promise support #1171

Open
Open
@nikhedonia

Description

@nikhedonia

Many JavaScript libraries are async and I have not seen that WebAssembly supports promises yet.
In order to easily write performant applications that leverage the JS ecosystem I'd suggest to add support of promises in imported functions.

For instance this should work:

const importObject = { 
  returnOneAsync: () => new Promise(done => done(1)) 
};
extern "C" int returnOneAsync();

int main(){
  int x = returnOneAsync(); // should suspend main until promise resolved.
  return x+x;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    asyncstack switching, JSPI, async, green threads, coroutines

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions