Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brotli breaks uncaughtException catcher #718

Open
scxr opened this issue Sep 23, 2024 · 1 comment
Open

Brotli breaks uncaughtException catcher #718

scxr opened this issue Sep 23, 2024 · 1 comment

Comments

@scxr
Copy link

scxr commented Sep 23, 2024

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    When using uniswap/smart-order-router which introduces the brotli (and by extension Emscripten) module it has broken process.on("uncaughtException")

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

This is the output when process.on("unhandledException") is triggered

/root/---/---node_modules/brotli/build/encode.js:3
1<process.argv.length?process.argv[1].replace(/\\/g,"/"):"unknown-program");b.arguments=process.argv.slice(2);"undefined"!==typeof module&&(module.exports=b);process.on("uncaughtException",function(a){if(!(a instanceof y))throw a;});b.inspect=function(){return"[Emscripten Module object]"}}else if(x)b.print||(b.print=print),"undefined"!=typeof printErr&&(b.printErr=printErr),b.read="undefined"!=typeof read?read:function(){throw"no read() available (jsc?)";},b.readBinary=function(a){if("function"===
                                                                                                                                                                                                                           

I believe it is related to this issue on brotli foliojs/brotli.js#37 however as far as im aware we do not have ability to determine how emcscript is compiled, please make it so by default this functionality is turned off

@scxr
Copy link
Author

scxr commented Sep 23, 2024

const originalOn = process.on;
process.on("uncaughtException", handleGlobalError);
process.on("unhandledRejection", handleGlobalError);
process.on = function (event, listener) {
    if ((event === 'uncaughtException' || event === 'unhandledRejection') &&
        (new Error().stack || '').includes('node_modules/brotli')) {
        console.warn(`Ignoring ${event} listener from brotli`);
        return process;
    }
    return originalOn.call(this, event, listener);
};

a temporary fix is this, however it is unideal (for anyone who happens to stumble upon this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant