Open jacksonloper opened 9 years ago
This is the nature of uncaughtException
- tripwire can't cause the while
statement to throw an error so you never get to your catch block.
So I would not expect the original code block to continue, but what exactly happens internally? It appears that the code/callback that caused the block has stopped, but is there no way to continue flush the event loop and continue with the process?
I added a callback in my context so that uncaughtException executes the callback in my game:
who Kriton the newbie
eval while(true);
*boom uncaughtException fires, I try and clear/reset tripWire and exec the callback which prints:
Command exceeded max execution time. <-- This was printed after the uncaught handler.
But now I am stuck in a loop where tripwire is firing an exception every 2000ms and I can't seem to clear or reset it. Here is what I am trying:
process.on('uncaughtException', err => {
let ctx = tripwire.getContext();
if (ctx) {
ctx.callback(ctx.input);
setImmediate(() => {
tripwire.clearTripwire();
});
}
logger.log(err);
logger.log(err.stack);
this.errorHandler(err, false);
});
I see V8 has a "CancelTerminateExecution()" that seems like it should be able to resume the original isolate/script once the event loop is all cleared out. My C++ is super rusty, though. I have created a fork of this project to try and get a working proof-of-concept.
After the tripwire fires, my script exits, whether I call
process.exit(1)
or not.For example, this code...
... prints "Hello" and "Doom" but not "Goodbye"
I suppose there's no way around this. It's presumably sort of the same problem as #1.