diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 2d36c1a2654aa6..42b9469e38189f 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -1141,12 +1141,11 @@ void TLSWrap::Initialize(Local target, env->SetProtoMethod(t, "getServername", GetServername); env->SetProtoMethod(t, "setServername", SetServername); - env->set_tls_wrap_constructor_function( - t->GetFunction(env->context()).ToLocalChecked()); + Local fn = t->GetFunction(env->context()).ToLocalChecked(); - target->Set(env->context(), - tlsWrapString, - t->GetFunction(env->context()).ToLocalChecked()).Check(); + env->set_tls_wrap_constructor_function(fn); + + target->Set(env->context(), tlsWrapString, fn).Check(); } } // namespace node