emscripten-core / emscripten-core/emscripten

Async-Await syntax on Asyncify causes "Unexpected token"

Open
#11,717 2 comments 0 reactions 0 assignees View on GitHub
asyncify
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I can use traditional call back style code with Asyncify but when I want to use async-await, the code doesn't compile well.

```

EM_JS(const char*, fetchSmth, (), {
return Asyncify.handleAsync(async()=>{
var response = await fetch("http://whatever.site.goes.here/");
var moduleFile = await response.text();

var lengthBytes = lengthBytesUTF8(moduleFile) + 1;
var result = _malloc(lengthBytes);
stringToUTF8(stringified, result, lengthBytes);

return result;
});
});
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.