emscripten-core / emscripten-core/emscripten

Embind causes "Cannot have multiple async operations in flight at once" assertion

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

Description

**Version of emscripten/emsdk:**
Reproduced wth 3.1.14 (relevant Emscripten code appears to be unchanged in later versions)

We're getting "Assertion failed: Cannot have multiple async operations in flight at once", with following stack trace:

```
abort @ VM977:1009
assert @ VM977:508
whenDone @ VM977:4714
qtStdWebEventCallbackActivate @ VM1024:11
```
Where the debugger shows this implementaton for qtStdWebEventCallbackActivate:

```
(function anonymous(throwBindingError,invoker,fn,runDestructors,retType,classParam,argType0,Asyncify
) {
return function qtStdWebEventCallbackActivate(arg0) {
if (arguments.length !== 1) {
throwBindingError('function qtStdWebEventCallbackActivate called with ' + arguments.length + ' arguments, expected 1 args!');
}
var arg0Wired = argType0.toWireType(null, arg0); // emscripten::val
invoker(fn, arg0Wired);
function onDone() {
}
return Asyncify.currData ? Asyncify.whenDone().then(onDone) : onDone();
}

})
```
Where whenDone() is:
```
whenDone: function() {
assert(Asyncify.currData, "Tried to wait for an async operation when none is in progress.");
assert(!Asyncify.asyncPromiseHandlers, "Cannot have multiple async operations in flight at once");
return new Promise((resolve, reject) => {
Asyncify.asyncPromiseHandlers = {
resolve: resolve,
reject: reject
};
});
},

```

The assertion is triggered in a case where there is an async operation in progress, which has already registered promise handlers. Should asyncPromiseHandlers support registering multiple promises?

See https://bugreports.qt.io/browse/QTBUG-102827 for the corresponding Qt bug, with a (Qt) example which reproduces the bug.

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.