File tree 4 files changed +13
-5
lines changed
4 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -1227,9 +1227,16 @@ changes:
1227
1227
used for generated code.
1228
1228
* ` stackSizeMb` {number} The default maximum stack size for the thread.
1229
1229
Small values may lead to unusable Worker instances. ** Default: ** ` 4` .
1230
- * ` name` {string} An optional ` name` to be appended to the worker title
1231
- for debugging/ identification purposes, making the final title as
1232
- ` [worker ${ id} ] ${ name} ` . ** Default: ** ` ''` .
1230
+ * ` name` {string} An optional ` name` to be replaced in the thread name
1231
+ and to the worker title for debugging/ identification purposes,
1232
+ making the final title as ` [worker ${ id} ] ${ name} ` .
1233
+ This parameter has a maximum allowed size, depending on the operating
1234
+ system . If the provided name exceeds the limit, it will be truncated
1235
+ * Maximum sizes:
1236
+ * Windows: 32 ,767 characters
1237
+ * macOS: 64 characters
1238
+ * Other systems: 16 characters
1239
+ ** Default: ** ` 'WorkerThread'` .
1233
1240
1234
1241
### Event : ` 'error'`
1235
1242
Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ class Worker extends EventEmitter {
204
204
options . env ) ;
205
205
}
206
206
207
- let name = '' ;
207
+ let name = 'WorkerThread ' ;
208
208
if ( options . name ) {
209
209
validateString ( options . name , 'options.name' ) ;
210
210
name = StringPrototypeTrim ( options . name ) ;
Original file line number Diff line number Diff line change @@ -740,6 +740,7 @@ void Worker::StartThread(const FunctionCallbackInfo<Value>& args) {
740
740
Worker* w = static_cast <Worker*>(arg);
741
741
const uintptr_t stack_top = reinterpret_cast <uintptr_t >(&arg);
742
742
743
+ uv_thread_setname (w->name_ .c_str ());
743
744
// Leave a few kilobytes just to make sure we're within limits and have
744
745
// some space to do work in C++ land.
745
746
w->stack_base_ = stack_top - (w->stack_size_ - kStackBufferSize );
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ if (isMainThread) {
23
23
assert ( traces . length > 0 ) ;
24
24
assert ( traces . some ( ( trace ) =>
25
25
trace . cat === '__metadata' && trace . name === 'thread_name' &&
26
- trace . args . name === '[worker 1]' ) ) ;
26
+ trace . args . name === '[worker 1] WorkerThread ' ) ) ;
27
27
} ) ) ;
28
28
} ) ) ;
29
29
} else {
You can’t perform that action at this time.
0 commit comments