@@ -790,62 +790,6 @@ bool ShouldAbortOnUncaughtException(Isolate* isolate) {
790
790
}
791
791
792
792
793
- Local<Value> GetDomainProperty (Environment* env, Local<Object> object) {
794
- Local<Value> domain_v =
795
- object->GetPrivate (env->context (), env->domain_private_symbol ())
796
- .ToLocalChecked ();
797
- if (domain_v->IsObject ()) {
798
- return domain_v;
799
- }
800
- return object->Get (env->context (), env->domain_string ()).ToLocalChecked ();
801
- }
802
-
803
-
804
- void DomainEnter (Environment* env, Local<Object> object) {
805
- Local<Value> domain_v = GetDomainProperty (env, object);
806
- if (domain_v->IsObject ()) {
807
- Local<Object> domain = domain_v.As <Object>();
808
- Local<Value> enter_v = domain->Get (env->enter_string ());
809
- if (enter_v->IsFunction ()) {
810
- if (enter_v.As <Function>()->Call (domain, 0 , nullptr ).IsEmpty ()) {
811
- FatalError (" node::AsyncWrap::MakeCallback" ,
812
- " domain enter callback threw, please report this" );
813
- }
814
- }
815
- }
816
- }
817
-
818
-
819
- void DomainExit (Environment* env, v8::Local<v8::Object> object) {
820
- Local<Value> domain_v = GetDomainProperty (env, object);
821
- if (domain_v->IsObject ()) {
822
- Local<Object> domain = domain_v.As <Object>();
823
- Local<Value> exit_v = domain->Get (env->exit_string ());
824
- if (exit_v->IsFunction ()) {
825
- if (exit_v.As <Function>()->Call (domain, 0 , nullptr ).IsEmpty ()) {
826
- FatalError (" node::AsyncWrap::MakeCallback" ,
827
- " domain exit callback threw, please report this" );
828
- }
829
- }
830
- }
831
- }
832
-
833
- void SetupDomainUse (const FunctionCallbackInfo<Value>& args) {
834
- Environment* env = Environment::GetCurrent (args);
835
-
836
- if (env->using_domains ())
837
- return ;
838
- env->set_using_domains (true );
839
-
840
- HandleScope scope (env->isolate ());
841
-
842
- // Do a little housekeeping.
843
- env->process_object ()->Delete (
844
- env->context (),
845
- FIXED_ONE_BYTE_STRING (args.GetIsolate (), " _setupDomainUse" )).FromJust ();
846
- }
847
-
848
-
849
793
void RunMicrotasks (const FunctionCallbackInfo<Value>& args) {
850
794
args.GetIsolate ()->RunMicrotasks ();
851
795
}
@@ -982,11 +926,6 @@ InternalCallbackScope::InternalCallbackScope(Environment* env,
982
926
// If you hit this assertion, you forgot to enter the v8::Context first.
983
927
CHECK_EQ (Environment::GetCurrent (env->isolate ()), env);
984
928
985
- if (asyncContext.async_id == 0 && env->using_domains () &&
986
- !object_.IsEmpty ()) {
987
- DomainEnter (env, object_);
988
- }
989
-
990
929
if (asyncContext.async_id != 0 ) {
991
930
// No need to check a return value because the application will exit if
992
931
// an exception occurs.
@@ -1016,11 +955,6 @@ void InternalCallbackScope::Close() {
1016
955
AsyncWrap::EmitAfter (env_, async_context_.async_id );
1017
956
}
1018
957
1019
- if (async_context_.async_id == 0 && env_->using_domains () &&
1020
- !object_.IsEmpty ()) {
1021
- DomainExit (env_, object_);
1022
- }
1023
-
1024
958
if (IsInnerMakeCallback ()) {
1025
959
return ;
1026
960
}
@@ -1061,7 +995,16 @@ MaybeLocal<Value> InternalMakeCallback(Environment* env,
1061
995
return Undefined (env->isolate ());
1062
996
}
1063
997
1064
- MaybeLocal<Value> ret = callback->Call (env->context (), recv, argc, argv);
998
+ Local<Function> domain_cb = env->domain_callback ();
999
+ MaybeLocal<Value> ret;
1000
+ if (asyncContext.async_id != 0 || domain_cb.IsEmpty () || recv.IsEmpty ()) {
1001
+ ret = callback->Call (env->context (), recv, argc, argv);
1002
+ } else {
1003
+ std::vector<Local<Value>> args (1 + argc);
1004
+ args[0 ] = callback;
1005
+ std::copy (&argv[0 ], &argv[argc], &args[1 ]);
1006
+ ret = domain_cb->Call (env->context (), recv, args.size (), &args[0 ]);
1007
+ }
1065
1008
1066
1009
if (ret.IsEmpty ()) {
1067
1010
// NOTE: For backwards compatibility with public API we return Undefined()
@@ -3339,7 +3282,6 @@ void SetupProcessObject(Environment* env,
3339
3282
env->SetMethod (process, " _setupProcessObject" , SetupProcessObject);
3340
3283
env->SetMethod (process, " _setupNextTick" , SetupNextTick);
3341
3284
env->SetMethod (process, " _setupPromises" , SetupPromises);
3342
- env->SetMethod (process, " _setupDomainUse" , SetupDomainUse);
3343
3285
}
3344
3286
3345
3287
0 commit comments