summaryrefslogtreecommitdiff
path: root/src/node_contextify.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-11-29 20:55:43 +0100
committerAnna Henningsen <anna@addaleax.net>2017-12-05 23:49:36 +0100
commitb73e66e94918aa89643b982cd3164100d02ec997 (patch)
treee23a4188d6330d7ea7bd34e9c04689c6f032cc5c /src/node_contextify.cc
parentaeddc3676bc9afe940106d34f30523f27b4cb44f (diff)
downloadandroid-node-v8-b73e66e94918aa89643b982cd3164100d02ec997.tar.gz
android-node-v8-b73e66e94918aa89643b982cd3164100d02ec997.tar.bz2
android-node-v8-b73e66e94918aa89643b982cd3164100d02ec997.zip
vm: never abort on caught syntax error
Keep track of C++ `TryCatch` state to avoid aborting when an exception is thrown inside one, and re-throw in JS to make sure the exception is being picked up a second time by a second uncaught exception handler, if necessary. Add a bit of a hack to `AppendExceptionLine` to avoid overriding the line responsible for re-throwing the exception. PR-URL: https://github.com/nodejs/node/pull/17394 Fixes: https://github.com/nodejs/node/issues/13258 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_contextify.cc')
-rw-r--r--src/node_contextify.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/node_contextify.cc b/src/node_contextify.cc
index 5b389f2ff8..09cdfc5cf5 100644
--- a/src/node_contextify.cc
+++ b/src/node_contextify.cc
@@ -621,6 +621,7 @@ class ContextifyScript : public BaseObject {
new ContextifyScript(env, args.This());
TryCatch try_catch(env->isolate());
+ Environment::ShouldNotAbortOnUncaughtScope no_abort_scope(env);
Local<String> code =
args[0]->ToString(env->context()).FromMaybe(Local<String>());
@@ -633,6 +634,7 @@ class ContextifyScript : public BaseObject {
Maybe<bool> maybe_produce_cached_data = GetProduceCachedData(env, options);
MaybeLocal<Context> maybe_context = GetContext(env, options);
if (try_catch.HasCaught()) {
+ no_abort_scope.Close();
try_catch.ReThrow();
return;
}
@@ -669,6 +671,7 @@ class ContextifyScript : public BaseObject {
if (v8_script.IsEmpty()) {
DecorateErrorStack(env, try_catch);
+ no_abort_scope.Close();
try_catch.ReThrow();
return;
}