I have a JS library which is generated from rust code using emscripten, when an exception is thrown the trace points to the emscripten generated code, even if the error is not in the library itself.
I have created this small repository to replicate the issue:
https://github.com/hugo-dc/wasm-demo
the index.js file just loads the generated js code, and then throw an exception, when the exception is thrown it shows the following output pointing out to the generated JS code:
/Users/hugo/workspace/wasm-demo/site/site.js:1
(function (exports, require, module, __filename, __dirname) { var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;if(Module["ENVIRONMENT"]){if(Module["ENVIRONMENT"]==="WEB"){ENVIRONMENT_IS_WEB=true}else if(Module["ENVIRONMENT"]==="WORKER"){ENVIRONMENT_IS_WORKER=true}else if(Module["ENVIRONMENT"]==="NODE"){ENVIRONMENT_IS_NODE=true}else if(Module["ENVIRONMENT"]==="SHELL"){ENVIRONMENT_IS_SHELL=true}else{throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.")}}else{ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WO
MyException
I see the generated JS code contains the following:
process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}))
If that code is removed, then I get different output, which is what I would expect:
/Users/hugo/workspace/wasm-demo/index.js:4
throw "MyException"
^
MyException
So, is there a way to get rid of that part of the code which is currently catching all exceptions? is there a way to tell emscripten to not generate it?.
I have a JS library which is generated from rust code using emscripten, when an exception is thrown the trace points to the emscripten generated code, even if the error is not in the library itself.
I have created this small repository to replicate the issue:
https://github.com/hugo-dc/wasm-demo
the index.js file just loads the generated js code, and then throw an exception, when the exception is thrown it shows the following output pointing out to the generated JS code:
I see the generated JS code contains the following:
If that code is removed, then I get different output, which is what I would expect:
So, is there a way to get rid of that part of the code which is currently catching all exceptions? is there a way to tell emscripten to not generate it?.