@@ -150,7 +150,6 @@ using v8::Number;
150150using v8::Object;
151151using v8::ObjectTemplate;
152152using v8::Promise;
153- using v8::PromiseHookType;
154153using v8::PromiseRejectMessage;
155154using v8::PropertyCallbackInfo;
156155using v8::ScriptOrigin;
@@ -1178,7 +1177,6 @@ bool ShouldAbortOnUncaughtException(Isolate* isolate) {
11781177 return isEmittingTopLevelDomainError || !DomainsStackHasErrorHandler (env);
11791178}
11801179
1181-
11821180Local<Value> GetDomainProperty (Environment* env, Local<Object> object) {
11831181 Local<Value> domain_v =
11841182 object->GetPrivate (env->context (), env->domain_private_symbol ())
@@ -1219,36 +1217,6 @@ void DomainExit(Environment* env, v8::Local<v8::Object> object) {
12191217 }
12201218}
12211219
1222-
1223- void DomainPromiseHook (PromiseHookType type,
1224- Local<Promise> promise,
1225- Local<Value> parent,
1226- void * arg) {
1227- Environment* env = static_cast <Environment*>(arg);
1228- Local<Context> context = env->context ();
1229-
1230- if (type == PromiseHookType::kInit && env->in_domain ()) {
1231- Local<Value> domain_obj =
1232- env->domain_array ()->Get (context, 0 ).ToLocalChecked ();
1233- if (promise->CreationContext () == context) {
1234- promise->Set (context, env->domain_string (), domain_obj).FromJust ();
1235- } else {
1236- // Do not expose object from another context publicly in promises created
1237- // in non-main contexts.
1238- promise->SetPrivate (context, env->domain_private_symbol (), domain_obj)
1239- .FromJust ();
1240- }
1241- return ;
1242- }
1243-
1244- if (type == PromiseHookType::kBefore ) {
1245- DomainEnter (env, promise);
1246- } else if (type == PromiseHookType::kAfter ) {
1247- DomainExit (env, promise);
1248- }
1249- }
1250-
1251-
12521220void SetupDomainUse (const FunctionCallbackInfo<Value>& args) {
12531221 Environment* env = Environment::GetCurrent (args);
12541222
@@ -1259,38 +1227,13 @@ void SetupDomainUse(const FunctionCallbackInfo<Value>& args) {
12591227 HandleScope scope (env->isolate ());
12601228 Local<Object> process_object = env->process_object ();
12611229
1262- Local<String> tick_callback_function_key = env->tick_domain_cb_string ();
1263- Local<Function> tick_callback_function =
1264- process_object->Get (tick_callback_function_key).As <Function>();
1265-
1266- if (!tick_callback_function->IsFunction ()) {
1267- fprintf (stderr, " process._tickDomainCallback assigned to non-function\n " );
1268- ABORT ();
1269- }
1270-
1271- process_object->Set (env->tick_callback_string (), tick_callback_function);
1272- env->set_tick_callback_function (tick_callback_function);
1273-
12741230 CHECK (args[0 ]->IsArray ());
1275- env->set_domain_array (args[0 ].As <Array>());
1276-
1277- CHECK (args[1 ]->IsArray ());
1278- env->set_domains_stack_array (args[1 ].As <Array>());
1231+ env->set_domains_stack_array (args[0 ].As <Array>());
12791232
12801233 // Do a little housekeeping.
12811234 env->process_object ()->Delete (
12821235 env->context (),
12831236 FIXED_ONE_BYTE_STRING (args.GetIsolate (), " _setupDomainUse" )).FromJust ();
1284-
1285- uint32_t * const fields = env->domain_flag ()->fields ();
1286- uint32_t const fields_count = env->domain_flag ()->fields_count ();
1287-
1288- Local<ArrayBuffer> array_buffer =
1289- ArrayBuffer::New (env->isolate (), fields, sizeof (*fields) * fields_count);
1290-
1291- env->AddPromiseHook (DomainPromiseHook, static_cast <void *>(env));
1292-
1293- args.GetReturnValue ().Set (Uint32Array::New (array_buffer, 0 , fields_count));
12941237}
12951238
12961239
@@ -1414,7 +1357,8 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
14141357 // If you hit this assertion, you forgot to enter the v8::Context first.
14151358 CHECK_EQ (Environment::GetCurrent (env->isolate ()), env);
14161359
1417- if (env->using_domains () && !object_.IsEmpty ()) {
1360+ if (asyncContext.async_id == 0 && env->using_domains () &&
1361+ !object_.IsEmpty ()) {
14181362 DomainEnter (env, object_);
14191363 }
14201364
@@ -1447,7 +1391,8 @@ void InternalCallbackScope::Close() {
14471391 AsyncWrap::EmitAfter (env_, async_context_.async_id );
14481392 }
14491393
1450- if (env_->using_domains () && !object_.IsEmpty ()) {
1394+ if (async_context_.async_id == 0 && env_->using_domains () &&
1395+ !object_.IsEmpty ()) {
14511396 DomainExit (env_, object_);
14521397 }
14531398
0 commit comments