Uniswap / smart-order-router

GNU General Public License v3.0
406 stars 404 forks source link

Brotli breaks uncaughtException catcher #718

Open scxr opened 6 days ago

scxr commented 6 days ago

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 https://github.com/foliojs/brotli.js/issues/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 commented 6 days ago
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)