emscripten-core / emscripten-core/emscripten
async error
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
emcc: 3.1.0
async error
During the execution of an asynchronous function, if other tasks are inserted, the state of the Promise function will always be pending
【code】
```
#include
#include
#include
#include
#include
using namespace emscripten;
class Test {
public:
void printf() {
for (int i = 0; i < 1000; i++) {
std::cout<<"i: "<(u8"encode", val(text));
val digestValue = val::global()[u8"crypto"][u8"subtle"].call(u8"digest", val(u8"SHA-256"), data).await();
val base64 = val::global().call(u8"btoa", val::global()[u8"String"][u8"fromCharCode"].call(u8"apply", val::null(), val::global()[u8"Uint8Array"].new_(digestValue)));
return base64;
}
};
EMSCRIPTEN_BINDINGS(main) {
class_("Test")
.smart_ptr_constructor("Test", &std::make_shared)
.function("printf", &Test::printf)
.function(u8"GetBase64Sha256Normal", &Test::GetBase64Sha256Normal);
}
```
js:
```
console.log("before ");
const res = await Promise.all([test.getBase64Sha256Normal("helloworld"), test.printf()]);
console.log("after: ", res);
```
would not print the last : "after ………"
Contributor guide
Assessment
This issue has not been assessed yet.