diff options
author | Gus Caplan <me@gus.host> | 2018-10-20 22:08:41 -0500 |
---|---|---|
committer | Gus Caplan <me@gus.host> | 2018-10-23 13:05:57 -0500 |
commit | 2caf0793c1e60b37851753d2eb219034be57da5f (patch) | |
tree | e66d306c504b0c36014ca7079ca9a2fa4930f4dd /src | |
parent | 3516052bee118dce767dd330fa857f6615c5b28a (diff) | |
download | android-node-v8-2caf0793c1e60b37851753d2eb219034be57da5f.tar.gz android-node-v8-2caf0793c1e60b37851753d2eb219034be57da5f.tar.bz2 android-node-v8-2caf0793c1e60b37851753d2eb219034be57da5f.zip |
lib: trigger uncaught exception handler for microtasks
PR-URL: https://github.com/nodejs/node/pull/23794
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/node.cc b/src/node.cc index c24dfce0ab..02d9765301 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1423,6 +1423,18 @@ void FatalException(Isolate* isolate, const TryCatch& try_catch) { } +static void FatalException(const FunctionCallbackInfo<Value>& args) { + Isolate* isolate = args.GetIsolate(); + Environment* env = Environment::GetCurrent(isolate); + if (env != nullptr && env->abort_on_uncaught_exception()) { + Abort(); + } + Local<Value> exception = args[0]; + Local<Message> message = Exception::CreateMessage(isolate, exception); + FatalException(isolate, exception, message); +} + + static void OnMessage(Local<Message> message, Local<Value> error) { // The current version of V8 sends messages for errors only // (thus `error` is always set). @@ -2161,6 +2173,10 @@ void LoadEnvironment(Environment* env) { return; } + Local<Function> trigger_fatal_exception = + env->NewFunctionTemplate(FatalException)->GetFunction(env->context()) + .ToLocalChecked(); + // Bootstrap Node.js Local<Object> bootstrapper = Object::New(env->isolate()); SetupBootstrapObject(env, bootstrapper); @@ -2168,7 +2184,8 @@ void LoadEnvironment(Environment* env) { Local<Value> node_bootstrapper_args[] = { env->process_object(), bootstrapper, - bootstrapped_loaders + bootstrapped_loaders, + trigger_fatal_exception, }; if (!ExecuteBootstrapper(env, node_bootstrapper.ToLocalChecked(), arraysize(node_bootstrapper_args), |