@@ -1118,62 +1118,6 @@ bool ShouldAbortOnUncaughtException(Isolate* isolate) {
1118
1118
}
1119
1119
1120
1120
1121
- Local<Value> GetDomainProperty (Environment* env, Local<Object> object) {
1122
- Local<Value> domain_v =
1123
- object->GetPrivate (env->context (), env->domain_private_symbol ())
1124
- .ToLocalChecked ();
1125
- if (domain_v->IsObject ()) {
1126
- return domain_v;
1127
- }
1128
- return object->Get (env->context (), env->domain_string ()).ToLocalChecked ();
1129
- }
1130
-
1131
-
1132
- void DomainEnter (Environment* env, Local<Object> object) {
1133
- Local<Value> domain_v = GetDomainProperty (env, object);
1134
- if (domain_v->IsObject ()) {
1135
- Local<Object> domain = domain_v.As <Object>();
1136
- Local<Value> enter_v = domain->Get (env->enter_string ());
1137
- if (enter_v->IsFunction ()) {
1138
- if (enter_v.As <Function>()->Call (domain, 0 , nullptr ).IsEmpty ()) {
1139
- FatalError (" node::AsyncWrap::MakeCallback" ,
1140
- " domain enter callback threw, please report this" );
1141
- }
1142
- }
1143
- }
1144
- }
1145
-
1146
-
1147
- void DomainExit (Environment* env, v8::Local<v8::Object> object) {
1148
- Local<Value> domain_v = GetDomainProperty (env, object);
1149
- if (domain_v->IsObject ()) {
1150
- Local<Object> domain = domain_v.As <Object>();
1151
- Local<Value> exit_v = domain->Get (env->exit_string ());
1152
- if (exit_v->IsFunction ()) {
1153
- if (exit_v.As <Function>()->Call (domain, 0 , nullptr ).IsEmpty ()) {
1154
- FatalError (" node::AsyncWrap::MakeCallback" ,
1155
- " domain exit callback threw, please report this" );
1156
- }
1157
- }
1158
- }
1159
- }
1160
-
1161
- void SetupDomainUse (const FunctionCallbackInfo<Value>& args) {
1162
- Environment* env = Environment::GetCurrent (args);
1163
-
1164
- if (env->using_domains ())
1165
- return ;
1166
- env->set_using_domains (true );
1167
-
1168
- HandleScope scope (env->isolate ());
1169
-
1170
- // Do a little housekeeping.
1171
- env->process_object ()->Delete (
1172
- env->context (),
1173
- FIXED_ONE_BYTE_STRING (args.GetIsolate (), " _setupDomainUse" )).FromJust ();
1174
- }
1175
-
1176
-
1177
1121
void RunMicrotasks (const FunctionCallbackInfo<Value>& args) {
1178
1122
args.GetIsolate ()->RunMicrotasks ();
1179
1123
}
@@ -1294,11 +1238,6 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
1294
1238
// If you hit this assertion, you forgot to enter the v8::Context first.
1295
1239
CHECK_EQ (Environment::GetCurrent (env->isolate ()), env);
1296
1240
1297
- if (asyncContext.async_id == 0 && env->using_domains () &&
1298
- !object_.IsEmpty ()) {
1299
- DomainEnter (env, object_);
1300
- }
1301
-
1302
1241
if (asyncContext.async_id != 0 ) {
1303
1242
// No need to check a return value because the application will exit if
1304
1243
// an exception occurs.
@@ -1328,11 +1267,6 @@ void InternalCallbackScope::Close() {
1328
1267
AsyncWrap::EmitAfter (env_, async_context_.async_id );
1329
1268
}
1330
1269
1331
- if (async_context_.async_id == 0 && env_->using_domains () &&
1332
- !object_.IsEmpty ()) {
1333
- DomainExit (env_, object_);
1334
- }
1335
-
1336
1270
if (IsInnerMakeCallback ()) {
1337
1271
return ;
1338
1272
}
@@ -1379,7 +1313,16 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
1379
1313
return Undefined (env->isolate ());
1380
1314
}
1381
1315
1382
- MaybeLocal<Value> ret = callback->Call (env->context (), recv, argc, argv);
1316
+ Local<Function> domain_cb = env->domain_callback ();
1317
+ MaybeLocal<Value> ret;
1318
+ if (asyncContext.async_id != 0 || domain_cb.IsEmpty () || recv.IsEmpty ()) {
1319
+ ret = callback->Call (env->context (), recv, argc, argv);
1320
+ } else {
1321
+ std::vector<Local<Value>> args (1 + argc);
1322
+ args[0 ] = callback;
1323
+ std::copy (&argv[0 ], &argv[argc], &args[1 ]);
1324
+ ret = domain_cb->Call (env->context (), recv, args.size (), &args[0 ]);
1325
+ }
1383
1326
1384
1327
if (ret.IsEmpty ()) {
1385
1328
// NOTE: For backwards compatibility with public API we return Undefined()
@@ -3635,7 +3578,6 @@ void SetupProcessObject(Environment* env,
3635
3578
env->SetMethod (process, " _setupProcessObject" , SetupProcessObject);
3636
3579
env->SetMethod (process, " _setupNextTick" , SetupNextTick);
3637
3580
env->SetMethod (process, " _setupPromises" , SetupPromises);
3638
- env->SetMethod (process, " _setupDomainUse" , SetupDomainUse);
3639
3581
}
3640
3582
3641
3583
0 commit comments