viz.js icon indicating copy to clipboard operation
viz.js copied to clipboard

global exception handler being added that causes gnarly stack traces

Open rtpg opened this issue 2 years ago • 2 comments

This library's emscriptem code sets up an uncaughtException listener at the top level if it is imported.

This handler will re-throw the error, causing the logging to print the exception source line as the minified single line of the project. So importing this library and then having an error will cause a big

const vizRenderSync = require("@aduh95/viz.js/sync")

function f(){
  return (undefined).a.b
}

f()

^ you can see the issue running this in node. The stack trace just dumps the entire file.

This seems to be related to https://github.com/emscripten-core/emscripten/issues/17228 and this specific part of the source

From that issue:

This is probably a duplicate of https://github.com/emscripten-core/emscripten/issues/11532 and https://github.com/emscripten-core/emscripten/issues/14270, could you try to add -sNODEJS_CATCH_EXIT=0 -sNODEJS_CATCH_REJECTION=0 to the linker invocation? Note that this requires at least Node v15 to work properly.

So I think if the configuration adds those two parameters then this library will no longer include that exception handler.

rtpg avatar Jan 13 '23 01:01 rtpg

I'd send in a PR for this but I honestly don't quite know where the linker step is in the Makefile so am unsure where this makes sense

rtpg avatar Jan 13 '23 01:01 rtpg

Alright, created a PR that locally worked as expected. Would definitely appreciate a merge + a release of this change, as right now my stack traces are very hard to read without this

rtpg avatar Jan 31 '23 02:01 rtpg