@@ -32,6 +32,7 @@ using v8::Isolate;
3232using v8::Local;
3333using v8::Locker;
3434using v8::Maybe;
35+ using v8::NewStringType;
3536using v8::Null;
3637using v8::Number;
3738using v8::Object;
@@ -88,6 +89,14 @@ Worker::Worker(Environment* env,
8889 Number::New (env->isolate (), static_cast <double >(thread_id_.id )))
8990 .Check ();
9091
92+ object ()
93+ ->Set (env->context (),
94+ env->thread_name_string (),
95+ String::NewFromUtf8 (env->isolate (),
96+ name_.data (),
97+ NewStringType::kNormal ,
98+ name_.size ()).ToLocalChecked ())
99+ .Check ();
91100 // Without this check, to use the permission model with
92101 // workers (--allow-worker) one would need to pass --allow-inspector as well
93102 if (env->permission ()->is_granted (
@@ -364,7 +373,8 @@ void Worker::Run() {
364373 std::move (exec_argv_),
365374 static_cast <EnvironmentFlags::Flags>(environment_flags_),
366375 thread_id_,
367- std::move (inspector_parent_handle_)));
376+ std::move (inspector_parent_handle_),
377+ name_));
368378 if (is_stopped ()) return ;
369379 CHECK_NOT_NULL (env_);
370380 env_->set_env_vars (std::move (env_vars_));
@@ -1149,6 +1159,16 @@ void CreateWorkerPerContextProperties(Local<Object> target,
11491159 Number::New (isolate, static_cast <double >(env->thread_id ())))
11501160 .Check ();
11511161
1162+ target
1163+ ->Set (env->context (),
1164+ env->thread_name_string (),
1165+ String::NewFromUtf8 (isolate,
1166+ env->thread_name ().data (),
1167+ NewStringType::kNormal ,
1168+ env->thread_name ().size ())
1169+ .ToLocalChecked ())
1170+ .Check ();
1171+
11521172 target
11531173 ->Set (env->context (),
11541174 FIXED_ONE_BYTE_STRING (isolate, " isMainThread" ),
0 commit comments