I've used a wasm module in my code (zstd-codec) and it just disabled any error warning from unhandled errors or promisse rejection. Node just exited without any notice or information about the problem.
I solved the problem just not using it anymore, but, is it supose to do that? Can a module just disable all node exception handling?
My question is about node, not about the module. Does node supose to let it happen? Can it be a bug in wasm support?
const ZstdCodec = require('zstd-codec').ZstdCodec;
//create async error
start().catch((err)=>{
console.log(err)
})
async function start(){
class test {
constructor () {
this.testin()
}
async testin() {
console.log(x) //cause error
console.log("aaaa")
}
}
let x = new test
console.log("aaa")
}
here is a reduced version:
const { ZstdCodec } = require('zstd-codec')
;(async () => x)()
Can a module just disable all node exception handling?
yes, you could e.g.:
process.on('unhandledRejection', e => void 0)
and it looks like the module is definitely tinkering with that:
https://raw.githubusercontent.com/yoshihitoh/zstd-codec/develop/js/lib/zstd-codec-binding.js search for unhandledRejection
and here is the fully reduced version with the code snipped from the zstd-codec module.
process['on']('unhandledRejection', function(reason, p) {
process['exit'](1)
})
;(async () => x)()
there you go ...
forgot to mention:
you should probably file a bug with the above module, and/or, better, with the LLVM/emscripten pipeline, depending on who is responsible.
here is a workaround for the interim:
const { ZstdCodec } = require('zstd-codec')
const [listener] = process.listeners('unhandledRejection')
process.removeListener('unhandledRejection', listener)
;(async () => x)()
Sounds like this is a bug from the Emscripten output… Closing.
Most helpful comment
forgot to mention:
you should probably file a bug with the above module, and/or, better, with the LLVM/emscripten pipeline, depending on who is responsible.
here is a workaround for the interim: