src: set worker thread name using worker.name · nodejs/node@3579143 · GitHub
Skip to content

Commit 3579143

Browse files
RafaelGSStargos
authored andcommitted
src: set worker thread name using worker.name
Set the worker thread name using worker.name value and changing the default to "WorkerThread" PR-URL: #56416 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
1 parent 736ff5d commit 3579143

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

doc/api/worker_threads.md

Lines changed: 10 additions & 3 deletions

lib/internal/worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Worker extends EventEmitter {
204204
options.env);
205205
}
206206

207-
let name = '';
207+
let name = 'WorkerThread';
208208
if (options.name) {
209209
validateString(options.name, 'options.name');
210210
name = StringPrototypeTrim(options.name);

src/node_worker.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ void Worker::StartThread(const FunctionCallbackInfo<Value>& args) {
740740
Worker* w = static_cast<Worker*>(arg);
741741
const uintptr_t stack_top = reinterpret_cast<uintptr_t>(&arg);
742742

743+
uv_thread_setname(w->name_.c_str());
743744
// Leave a few kilobytes just to make sure we're within limits and have
744745
// some space to do work in C++ land.
745746
w->stack_base_ = stack_top - (w->stack_size_ - kStackBufferSize);

test/parallel/test-trace-events-worker-metadata.js

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)