summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/node.cc b/src/node.cc
index 1ad02e993..624865b55 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -909,6 +909,33 @@ Local<Value> WinapiErrnoException(Isolate* isolate,
#endif
+static bool IsDomainActive(const Environment* env) {
+ if (!env->using_domains()) {
+ return false;
+ }
+
+ Local<Array> domain_array = env->domain_array().As<Array>();
+ uint32_t domains_array_length = domain_array->Length();
+ if (domains_array_length == 0)
+ return false;
+
+ Local<Value> domain_v = domain_array->Get(0);
+ return !domain_v->IsNull();
+}
+
+
+bool ShouldAbortOnUncaughtException(v8::Isolate* isolate) {
+ Environment* env = Environment::GetCurrent(isolate);
+ Local<Object> process_object = env->process_object();
+ Local<String> emitting_top_level_domain_error_key =
+ env->emitting_top_level_domain_error_string();
+ bool isEmittingTopLevelDomainError =
+ process_object->Get(emitting_top_level_domain_error_key)->BooleanValue();
+
+ return !IsDomainActive(env) || isEmittingTopLevelDomainError;
+}
+
+
void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args.GetIsolate());
@@ -2772,6 +2799,9 @@ void SetupProcessObject(Environment* env,
// pre-set _events object for faster emit checks
process->Set(env->events_string(), Object::New(env->isolate()));
+
+ process->Set(env->emitting_top_level_domain_error_string(),
+ False(env->isolate()));
}
@@ -3453,6 +3483,8 @@ void Init(int* argc,
node_isolate = Isolate::New();
Isolate::Scope isolate_scope(node_isolate);
+ node_isolate->SetAbortOnUncaughtException(ShouldAbortOnUncaughtException);
+
#ifdef __POSIX__
// Raise the open file descriptor limit.
{ // NOLINT (whitespace/braces)