Node: Unhandled errors warning disabled by a WASM module

Created on 24 Jul 2018  Â·  3Comments  Â·  Source: nodejs/node

  • node v8.11.3:
  • Ubuntu 16.04 Linux uservm 4.15.0-24-generic #26~16.04.1:
  • UnhandledPromisseRejectionWarning:

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?

Here is the code to replicate that:

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")
}

question

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:

const { ZstdCodec } = require('zstd-codec')

const [listener] = process.listeners('unhandledRejection')
process.removeListener('unhandledRejection', listener)

;(async () => x)()

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filipesilvaa picture filipesilvaa  Â·  3Comments

seishun picture seishun  Â·  3Comments

mcollina picture mcollina  Â·  3Comments

danielstaleiny picture danielstaleiny  Â·  3Comments

danialkhansari picture danialkhansari  Â·  3Comments