Skip to content
Prev Previous commit
Next Next commit
Ignore ExitStatus exceptions
This should fix these errors:

    [wasm test] [23:10:04] dbug: Reached wasm exit
    [wasm test] [23:10:04] info: node:internal/process/promises:246
    [wasm test] [23:10:04] info:           triggerUncaughtException(err, true /* fromPromise */);
    [wasm test] [23:10:04] info:           ^
    [wasm test] [23:10:04] info:
    [wasm test] [23:10:04] info: [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<ExitStatus>".] {
    [wasm test] [23:10:04] info:   code: 'ERR_UNHANDLED_REJECTION'
    [wasm test] [23:10:04] info: }
    [wasm test] [23:10:04] info:
    [wasm test] [23:10:04] info: Node.js v17.3.1
    [wasm test] [23:10:04] info: Process node.exe exited with 1
  • Loading branch information
radekdoulik committed Mar 28, 2023
commit 81672f4243de7e3b0dba7f744ceb3945f1328352
10 changes: 10 additions & 0 deletions src/mono/wasm/test-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ if (is_node && process.versions.node.split(".")[0] < 14) {
throw new Error(`NodeJS at '${process.execPath}' has too low version '${process.versions.node}'`);
}

if (is_node) {
// the emscripten 3.1.34 stopped handling these when MODULARIZE is enabled
process.on('uncaughtException', function(ex) {
// ignore ExitStatus exceptions
if (ex !== 'unwind' && !(ex instanceof ExitStatus) && !(ex.context instanceof ExitStatus)) {
throw ex;
}
});
}

if (!is_node && !is_browser && typeof globalThis.crypto === 'undefined') {
// **NOTE** this is a simple insecure polyfill for testing purposes only
// /dev/random doesn't work on js shells, so define our own
Expand Down