emscripten-core / emscripten-core/emscripten
With minimal runtime wasm compilation errors are uncaught
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
**Version of emscripten/emsdk:**
latest source (currently `3.1.44-git`)
When compiling against the minimal runtime (`-s MINIMAL_RUNTIME=2`) emscripten generates a loader that leaves the ready promise unresolved forever. With assertions disabled there are no logs (aside from the browser uncaught exception handler)
[`postamble_minimal.js`](https://github.com/emscripten-core/emscripten/blob/96df1a79c63c98deed58b18291f914cbc1208771/src/postamble_minimal.js#L140C1-L260) will generate code that looks roughly like this (with assertions disabled)
```
WebAssembly.instantiate(Module['wasm'], imports).then((output) => {
// initialize module
ready();
});
```
This means that if the promise returned by `WebAssembly.instantiate` is rejected the error is lost (although it will trigger the browser uncaught exception handler).
With assertions enabled there is at least a log, but the ready promise is still not rejected, but this will not trigger the uncaught exception handler.
```
WebAssembly.instantiate(Module['wasm'], imports).then((output) => {
// initialize module
ready();
}, (error) => {
console.error(error);
});
```
The error should likely always be caught and used to reject the ready promise, similar to what is done in the normal runtime, which appears to always handle the error by calling [`abort`](https://github.com/emscripten-core/emscripten/blob/96df1a79c63c98deed58b18291f914cbc1208771/src/preamble.js#L849), which then [calls `readyPromiseReject`](https://github.com/emscripten-core/emscripten/blob/96df1a79c63c98deed58b18291f914cbc1208771/src/preamble.js#L491C3-L491C21).
Contributor guide
Assessment
This issue has not been assessed yet.