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

recover from tripwire firing #8

Open
jacksonloper opened this issue Nov 3, 2015 · 3 comments
Open

recover from tripwire firing #8

jacksonloper opened this issue Nov 3, 2015 · 3 comments

Comments

@jacksonloper
Copy link

After the tripwire fires, my script exits, whether I call process.exit(1) or not.

For example, this code...

var tripwire = require("tripwire");

process.on('uncaughtException', function (e) {
   console.log('Doom');
});

tripwire.resetTripwire(2000);

console.log("Hello")
try { 
    while(true) {}
} catch(err) {
    console.log("Goodbye");
}

... 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.

@rpaterson
Copy link

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.

@kristianoye
Copy link

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


@kristianoye
Copy link

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.

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

3 participants