emscripten-core / emscripten-core/emscripten
`emscripten_force_exit` waits for scheduled work
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
Example:
```c
#include
#include
static void delayedWork(void *unused) {
puts("2");
}
int main() {
puts("1");
emscripten_async_call(delayedWork, NULL, 5000);
emscripten_force_exit(0);
}
```
When executed in either Node.js or browser, you can see that it attempts to execute the scheduled work and fails on assertions because runtime counters are already zeroed:
```
> node a.out.js
1
Aborted(Assertion failed)
/home/rreverser/emscripten/a.out.js:127
throw ex;
^
RuntimeError: Aborted(Assertion failed)
at abort (/home/rreverser/emscripten/a.out.js:648:11)
at assert (/home/rreverser/emscripten/a.out.js:361:5)
at runtimeKeepalivePop (/home/rreverser/emscripten/a.out.js:1200:7)
at Timeout._onTimeout (/home/rreverser/emscripten/a.out.js:1207:9)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
Node.js v19.9.0
```
Additionally, in Node.js it's particularly obvious that it waits those 5 seconds for the scheduled work to finish.
I believe, based on the description, `emscripten_force_exit` should exit without waiting for any work or attempting to execute it.
Contributor guide
Assessment
This issue has not been assessed yet.