Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v19.8.0 release proposal #47087

Merged
merged 216 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
216 commits
Select commit Hold shift + click to select a range
66016e2
test_runner: display skipped tests in spec reporter output
richiemccoll Feb 18, 2023
95bbd0f
test: update web-platform tests for url
anonrig Feb 7, 2023
9d55a5e
url: fix url spec compliance issues
anonrig Feb 7, 2023
a524055
url: improve performance by removing host
anonrig Feb 14, 2023
fb146ee
deps: update simdutf to 3.2.0
nodejs-github-bot Feb 19, 2023
1f38657
stream: fix pipeline callback not called on ended stream
debadree25 Feb 19, 2023
617b5b1
tools: update wpt.fyi used daily checkout ref
panva Feb 19, 2023
c1651be
lib: add AsyncLocalStorage.bind() and .snapshot()
flakey5 Jan 28, 2023
9b6270a
src: implement DataQueue
jasnell Dec 17, 2022
36f36b9
src: update Blob implementation to use DataQueue / File-backed Blobs
jasnell Dec 17, 2022
d48ed95
src, lib: fixup lint and format issues for DataQueue/Blob
jasnell Dec 17, 2022
16bbbac
cluster: add trailing commas in source files
aduh95 Feb 20, 2023
4c12e6e
fs: add trailing commas in source files
aduh95 Feb 20, 2023
7b5c00a
lib: add trailing commas in `internal/perf`
aduh95 Feb 20, 2023
e5b8597
os: improve network interface performance
BridgeAR Feb 20, 2023
320ddc0
test_runner: centralize CLI option handling
cjihrig Feb 20, 2023
3401315
test: use newish OpenSSL feature in test-tls-dhe
tniessen Feb 20, 2023
b7e027a
tools: update lint-md-dependencies to rollup@3.17.0
nodejs-github-bot Feb 18, 2023
6ff0b80
tools: update lint-md-dependencies to rollup@3.17.1
nodejs-github-bot Feb 19, 2023
a38de61
assert: remove deprecated getFunction() usage
BridgeAR Feb 20, 2023
c786ed3
deps: V8: cherry-pick 90be99fab31c
targos Feb 20, 2023
86b3621
benchmark: rework assert benchmarks for correctness
BridgeAR Feb 9, 2023
abba45e
test: remove obsolete util.isDeepStrictEqual tests
BridgeAR Feb 10, 2023
7f85a2c
assert,util: improve deep equal comparison performance
BridgeAR Feb 9, 2023
e07c9b8
assert,util: revert recursive breaking change
BridgeAR Feb 14, 2023
dd66c48
doc: add emit to NodeEventTarget
deokjinkim Jan 26, 2023
19b5d07
src: use string_view for report and related code
addaleax Feb 20, 2023
2eb8875
events: add listener argument to listenerCount
ShogunPanda Feb 21, 2023
6f9cb98
http: unify header treatment
marco-ippolito Feb 21, 2023
d5784c7
test: fix flaky test-watch-mode-files_watcher
MoLow Feb 19, 2023
518b890
Revert "src: let http2 streams end after session close"
Trott Feb 21, 2023
1c6a92b
lib: update punycode to 2.3.0
anonrig Feb 18, 2023
d3d76c3
punycode: add pending deprecation
aduh95 Sep 7, 2020
ad5f42d
src: add SetFastMethodNoSideEffect()
joyeecheung Feb 21, 2023
9d63ac2
meta: update AUTHORS
nodejs-github-bot Feb 21, 2023
2ff9b20
tools: update-nghttp2 preserve config.h
marco-ippolito Feb 21, 2023
a560a78
tools: update nghttp2 action
marco-ippolito Feb 17, 2023
dd40034
tools: fixed path
marco-ippolito Feb 17, 2023
7806cae
doc: maintaining nghttp2
marco-ippolito Feb 21, 2023
25ccaa7
tools: fix regex strings in Python tools
josusky Feb 9, 2023
d627164
doc: clarify semver-minor notable changes approach
BethGriggs Feb 21, 2023
973287a
src: per-realm binding data
legendecas Feb 21, 2023
1756830
tools: use actions pinned by commit hash in coverage-linux
gabibguti Jan 20, 2023
4df0084
tls: add trailing commas in source files
aduh95 Feb 22, 2023
83b529f
debugger: add trailing commas in source files
aduh95 Feb 12, 2023
d4899b2
build,test: add proper support for IBM i
dmabupt Feb 22, 2023
f4cdc6f
test: remove OpenSSL 1.0.2 error message compat
tniessen Feb 22, 2023
694659c
tools: cleanup WPT refs in daily-wpt-fyi.yml
panva Feb 22, 2023
60e5f45
wasi: add support for version when creating WASI
mhdawson Jan 31, 2023
88057dd
doc: add in security steward for recent release
mhdawson Feb 17, 2023
d9069e7
deps: fix libuv for android
nappy Feb 22, 2023
68dde38
deps: update nghttp2 to 1.52.0
targos Feb 22, 2023
c0fcad3
src: use an array for faster binding data lookup
joyeecheung Feb 11, 2023
1b3a25e
doc: include context on .toWeb() parameters
debadree25 Feb 22, 2023
b2cfcf9
test: fix default WPT titles
panva Feb 22, 2023
fc319d6
doc: add test:coverage event to custom reporter examples
richiemccoll Feb 23, 2023
e0d098b
net: rework autoSelectFamily implementation
ShogunPanda Feb 23, 2023
e08514e
http: fix validation of "Link" header
SRHerzog Feb 23, 2023
aac5c28
http: correctly calculate strict content length
ronag Feb 23, 2023
9890eaa
benchmark: fix worker startup benchmark
joyeecheung Feb 23, 2023
2c4f670
test: fix IPv6 checks on IBM i
abmusse Feb 23, 2023
00edc50
doc: add document for profiling and heap snapshot
cola119 May 9, 2022
60d1a48
doc: document how to use the tls.DEFAULT_CIPHERS
andreas-ibm Feb 23, 2023
4e9915e
test: include strace openat test
RafaelGSS Feb 23, 2023
58b1f33
node-api: add __wasm32__ guards on async works
legendecas Feb 24, 2023
4f2bf8c
repl: add trailing commas in source files
aduh95 Feb 24, 2023
81592ff
child_process: add trailing commas in source files
aduh95 Feb 24, 2023
a92be13
test: improve control flow in test-tls-dhe
tniessen Feb 24, 2023
f6bd145
tools: run format-cpp on node-api test c files
legendecas Feb 24, 2023
9c7a2e3
test: fix test-v8-collect-gc-profile-in-worker.js
theanarkh Feb 24, 2023
93e91f3
stream: fix respondWithNewView() errors when view.byteOffset != 0
debadree25 Feb 24, 2023
dfe529b
test_runner: better handle async bootstrap errors
cjihrig Feb 24, 2023
4e0b932
meta: update CODEOWNERS of url implementations
anonrig Feb 24, 2023
4e18e0a
deps: update ada to 1.0.3
nodejs-github-bot Feb 24, 2023
5a3ad87
url: simplify and improve url formatting
anonrig Feb 24, 2023
bd5ef38
doc: add marco-ippolito to collaborators
marco-ippolito Feb 24, 2023
1e20b05
url: implement URLSearchParams size getter
jasnell Jan 22, 2023
92f2f19
deps: upgrade npm to 9.5.1
npm-cli-bot Feb 25, 2023
247dfb7
dgram: fix unhandled exception aborting a closed udp socket
vramana Feb 25, 2023
e52ad92
test: remove unreachable return
jakecastelli Feb 25, 2023
c7f056c
meta: remove unnecessary onboarding step
Trott Feb 25, 2023
3daf508
test: stop faking performance idlharness
panva Feb 25, 2023
76a9634
test: isolate hr-time specific wpt global init
panva Feb 25, 2023
3234155
test: remove useless require('../common') from WPTs
panva Feb 25, 2023
aa41f27
test_runner: add `describe.only` and `it.only` shorthands
richiemccoll Feb 21, 2023
2f09d3f
tools: update lint-md-dependencies to rollup@3.17.2
nodejs-github-bot Feb 25, 2023
281f176
lib: fix DOMException property descriptors after being lazy loaded
panva Feb 25, 2023
151fb60
deps: update simdutf to 3.2.1
nodejs-github-bot Feb 25, 2023
3ab1aab
test: remove useless WPT init scripts
panva Feb 25, 2023
bd097ca
test: update encoding WPTs
panva Feb 25, 2023
4b91420
tools: upload daily WPT Report to both staging and production
panva Feb 25, 2023
e5fa7a1
test: fix WPT title when no META title is present
panva Feb 25, 2023
f21ed3a
test: simplify test-tls-alert
tniessen Feb 25, 2023
e585a11
test: fix test-net-connect-reset-until-connected
batrla Feb 25, 2023
f4cbe4e
tools: update lint-md-dependencies to rollup@3.17.3
nodejs-github-bot Feb 26, 2023
760a351
benchmark: add benchmark for EventTarget add and remove
debadree25 Feb 26, 2023
48cf984
doc: add steps about signing the binary in single-executable docs
RaisinTen Feb 22, 2023
f914bff
lib: add trailing commas to more internal files
aduh95 Feb 26, 2023
df155b8
test: fix os-release check for Ubuntu in SEA test
addaleax Feb 26, 2023
8b1afe3
deps: update corepack to 0.17.0
nodejs-github-bot Feb 26, 2023
4ad48d9
stream: always delay construct callback by a nextTick
mcollina Feb 26, 2023
f558797
tools: fix linter message when using global `DOMException`
aduh95 Feb 26, 2023
04166fe
benchmark: split `Buffer.byteLength` benchmark
joyeecheung Feb 11, 2023
b3e1034
buffer: use v8 fast API calls for `Buffer.byteLength` implementation
joyeecheung Feb 11, 2023
e11f08e
assert: fix exception message for assert(0) on try catch block
hidecology Feb 26, 2023
2fece54
buffer: add Buffer.copyBytesFrom(...)
jasnell Feb 4, 2023
4e18651
lib: rename internal module declaration as internal bindings
okmttdhr Feb 27, 2023
f886681
stream: enable usage of webstreams on compose()
debadree25 Feb 27, 2023
724f9d6
tools: create llhttp update action
marco-ippolito Feb 27, 2023
cc74821
bootstrap: print stack trace during environment creation failure
joyeecheung Feb 6, 2023
9fab228
src: fix cb scope bugs involved in termination
ywave620 Feb 28, 2023
9d2532e
doc: use destructing import
jakecastelli Feb 26, 2023
c0b6413
doc: sort import order
jakecastelli Feb 26, 2023
25069a6
timers: use V8 fast API calls
joyeecheung Feb 28, 2023
8aca3cf
doc: add history info for `node:test`
aduh95 Feb 28, 2023
b199acd
meta: remove AUTHORS file
Trott Feb 28, 2023
b825e2d
deps: update ada to 1.0.4
nodejs-github-bot Feb 28, 2023
078600c
tools: update eslint to 8.35.0
nodejs-github-bot Feb 28, 2023
578a2c5
src: do not track BaseObjects directly in Realm
joyeecheung Feb 28, 2023
77b4aca
vm: fix leak in vm.compileFunction when importModuleDynamically is used
joyeecheung Feb 22, 2023
0d9c345
src: remove shadowed variable in OptionsParser
codebytere Mar 1, 2023
6fa142d
test: move socket from CWD to temporary directory
LiviaMedeiros Mar 1, 2023
08bf015
lib: fix BroadcastChannel initialization location
codebytere Mar 1, 2023
b10fe58
url: improve `isURLThis` detection
anonrig Mar 1, 2023
0e45470
test: update web-platform tests for url
meixg Mar 1, 2023
132fc45
tools: fix daily wpt nightly version selection
panva Mar 1, 2023
c7d4ff3
repl: fix .load infinite loop caused by shared use of lineEnding RegExp
Theo-Steiner Mar 1, 2023
56dbb15
repl: remove lastInputPreview conditional check
jenthone Mar 1, 2023
32bd38f
src: make util.h self-containted
joyeecheung Feb 24, 2023
f8765be
url: remove unused `kFormat` from url
anonrig Feb 27, 2023
92a6138
doc: fix stream iterator helpers examples
benjamingr Mar 1, 2023
7ab7f97
deps: update uvwasi to v0.0.16
mhdawson Feb 23, 2023
b2a80d7
wasi: add wasi sock_accept stub
mhdawson Jan 30, 2023
f9739a8
doc: add request to hold off publicising sec releases
mhdawson Feb 17, 2023
b8560ec
url: remove unnecessary call to `FunctionPrototypeBind`
aduh95 Mar 1, 2023
fb1ac98
deps: update simdutf to 3.2.2
nodejs-github-bot Mar 1, 2023
db2ace1
test: assume priv ports start at 1024 if it can't be changed
KrayzeeKev Mar 2, 2023
ecce647
tools: refactor dep_updaters
tony-go Mar 2, 2023
4b3b009
build: fix Visual Studio installation detection for Arm64
Blackhex Mar 2, 2023
b1747fe
url: set `formatUrl` method as no side effect
anonrig Mar 2, 2023
074692a
src: fix missing trailing ,
zcbenz Mar 2, 2023
6740679
src: fix negative nodeTiming milestone values
legendecas Feb 9, 2023
f4a59b7
tools: add automation for updating OpenSSL dependency
facutuesca Nov 24, 2022
e5b8896
test: move testPath from CWD to temporary directory
LiviaMedeiros Mar 3, 2023
2c621d6
esm: add a runtime warning when using import assertions
aduh95 Mar 3, 2023
282bf29
doc: fix fs missing import
jakecastelli Mar 3, 2023
553fd5b
doc: fix links to SSL_CTX_set_options
tniessen Mar 4, 2023
07036cf
doc: add release key for Juan Arboleda
juanarbol Mar 5, 2023
762dc7c
test_runner: align behavior of it and test
MoLow Feb 28, 2023
21153f1
test: simplify test-tls-ecdh-auto
tniessen Mar 5, 2023
8723844
tools: update lint-md-dependencies to rollup@3.18.0
nodejs-github-bot Mar 5, 2023
1b555ae
doc: use number which is bigger than 1024 as port in http2
deokjinkim Mar 6, 2023
6f18b94
doc: fix port of destination server is not defined in http2
deokjinkim Mar 6, 2023
ba5ff15
doc: improve fs code example quality
jakecastelli Mar 4, 2023
5fdd3f4
doc: fix description of TLS dhparam option
tniessen Mar 6, 2023
a646a22
worker: add support for worker name in inspector and trace_events
debadree25 Mar 6, 2023
f903ea5
doc: remove useless SSL_OP_* options
tniessen Mar 6, 2023
acfd9b8
test: improve test coverage of lib/dns
paivaandeerson Feb 23, 2023
adff278
deps,test: update postject to 1.0.0-alpha.5
nodejs-github-bot Mar 3, 2023
c8d528e
test: update WPT resources, common, streams, FileAPI, broadcastchannel
panva Mar 2, 2023
9d4d916
esm: fix import assertion warning
aduh95 Mar 7, 2023
4b7198c
test_runner: give the root test a harness reference
cjihrig Mar 5, 2023
069ff1c
test_runner: remove root tracking set
cjihrig Mar 5, 2023
0617c5e
benchmark: stablize encode benchmark
joyeecheung Feb 11, 2023
dcba3a0
src: move encoding bindings to a new binding
joyeecheung Feb 11, 2023
6b60f38
src: use AliasedUint32Array for encodeInto results
joyeecheung Feb 11, 2023
9e65996
src: remove unused `v8::Uint32Array` from encoding
anonrig Mar 8, 2023
774eb19
http: use listenerCount when adding noop event
ShogunPanda Mar 8, 2023
67e20f5
doc: fix myUrl is not defined in url
recrack Mar 8, 2023
5f0f1c4
doc: fix history information for `node:diagnostics_channel`
tlhunter Mar 8, 2023
63a83b4
typings: improve `primordials` typings
aduh95 Mar 8, 2023
17d3eb0
doc: add missing test runner flags to man page
cjihrig Mar 8, 2023
b051ac7
src: remove use of SSL_OP_SINGLE_DH_USE
tniessen Mar 4, 2023
815d2af
src: remove TLSEXT_TYPE_alpn guard
tniessen Mar 4, 2023
5b81689
test: simplify test-tls-ecdh-multiple
tniessen Mar 5, 2023
13f14a5
test,crypto: update WebCryptoAPI WPT
panva Mar 10, 2023
4219c1e
meta: add single-executable labels and code owners
joyeecheung Mar 10, 2023
e754277
url: fix array overrun in node:url::SetArgs()
anonrig Mar 10, 2023
40a7b0b
net: fix setting of value in 'setDefaultAutoSelectFamilyAttemptTimeout'
deokjinkim Mar 10, 2023
cbdaaf6
doc: fix typo on esm loaders example
ruyadorno Mar 10, 2023
2e7ba31
tools: automate cares update
marco-ippolito Mar 10, 2023
9556d98
test: fallback to IPv4 if IPv6 is unavailable
abmusse Mar 11, 2023
0f1ecbc
tools: dont use cached node versions in daily wpt
panva Mar 11, 2023
458671d
doc,test: extend the list of platforms supported by single-executables
RaisinTen Mar 11, 2023
258d5f7
benchmark: replace table in docs with description of file tree structure
Theo-Steiner Mar 11, 2023
11509a4
test: move `test-tls-autoselectfamily-servername` to `test/internet`
aduh95 Mar 11, 2023
afbd818
debugger: add a command to set which lines to check for context
Dailyscat Mar 12, 2023
bb9b1c6
tls: support automatic DHE
tniessen Mar 12, 2023
94882f5
doc: amend support tier qualifier
gireeshpunathil Apr 21, 2022
2b7eb56
debugger: improve validations and documents for watch and unwatch
Dailyscat Mar 13, 2023
7cfd31a
benchmark: add a benchmark for URLSearchParams creation and toString()
debadree25 Mar 13, 2023
89f31a1
doc: fix typo in test.md
vhiairrassary Mar 13, 2023
c972612
test: fix flakyness in test-runner reporter test
MoLow Dec 22, 2022
3a1a7fa
test_runner: flatten TAP output when running using `--test`
MoLow Feb 18, 2023
ffa86f7
test_runner: emit test-only diagnostic warning
richiemccoll Feb 21, 2023
6d32a16
test_runner: bootstrap reporters before running tests
MoLow Feb 19, 2023
1a23eab
events: add trailing commas in source files
aduh95 Feb 24, 2023
345c8c3
lib,src: fix a few typos in comments
tniessen Feb 25, 2023
ecf714e
test_runner: reset count on watch mode
MoLow Feb 8, 2023
5c7fc92
lib: add trailing commas to all public core modules
aduh95 Feb 12, 2023
1fa6352
url: offload `URLSearchParams` initialization
anonrig Feb 27, 2023
0923cbc
test_runner: fix reconstruction of errors extracted from YAML
MoLow Mar 1, 2023
debc0ad
test_runner: avoid running twice tests in describe
MoLow Feb 28, 2023
05614f8
lib: enforce use of trailing commas
aduh95 Feb 28, 2023
b832d77
test_runner: track bootstrapping process
cjihrig Mar 5, 2023
7960ccb
test_runner: throw if harness is not bootstrapped
cjihrig Mar 5, 2023
18146fc
test_runner: handle errors not bound to tests
cjihrig Feb 16, 2023
5e31599
test_runner: default to spec reporter when on TTY environment
MoLow Mar 6, 2023
5eb5be8
esm: move hooks handling into separate class
GeoffreyBooth Dec 20, 2022
18f0398
esm: allow resolve to return import assertions
GeoffreyBooth Jan 12, 2023
c310a32
doc: remove remaining SSL_OP_NETSCAPE_*_BUG
tniessen Mar 13, 2023
ed31316
src: use std::array for passing argv in node::url
addaleax Mar 13, 2023
84f5a1f
deps: update undici to 5.21.0
nodejs-github-bot Mar 13, 2023
12a5618
tools: add undici WPTs to daily WPT Report
panva Feb 25, 2023
36c48ea
tools: add daily WPT Report workflow step summary
panva Feb 25, 2023
4221dce
2023-03-14, Version 19.8.0 (Current)
targos Mar 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
worker: add support for worker name in inspector and trace_events
Fixes: #41589
PR-URL: #46832
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
debadree25 authored and targos committed Mar 14, 2023
commit a646a22d0f26314d44ce24b0dd200e4289297996
7 changes: 7 additions & 0 deletions doc/api/worker_threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,10 @@ if (isMainThread) {
<!-- YAML
added: v10.5.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/46832
description: Added support for a `name` option, which allows
adding a name to worker title for debugging.
- version: v14.9.0
pr-url: https://github.com/nodejs/node/pull/34584
description: The `filename` parameter can be a WHATWG `URL` object using
Expand Down Expand Up @@ -1004,6 +1008,9 @@ changes:
used for generated code.
* `stackSizeMb` {number} The default maximum stack size for the thread.
Small values may lead to unusable Worker instances. **Default:** `4`.
* `name` {string} An optional `name` to be appended to the worker title
for debuggin/identification purposes, making the final title as
`[worker ${id}] ${name}`. **Default:** `''`.

### Event: `'error'`

Expand Down
12 changes: 10 additions & 2 deletions lib/internal/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const {
SafeArrayIterator,
SafeMap,
String,
StringPrototypeTrim,
Symbol,
SymbolFor,
TypedArrayPrototypeFill,
Expand Down Expand Up @@ -57,7 +58,7 @@ const {
const { deserializeError } = require('internal/error_serdes');
const { fileURLToPath, isURLInstance, pathToFileURL } = require('internal/url');
const { kEmptyObject } = require('internal/util');
const { validateArray } = require('internal/validators');
const { validateArray, validateString } = require('internal/validators');

const {
ownsProcessState,
Expand Down Expand Up @@ -188,12 +189,19 @@ class Worker extends EventEmitter {
options.env);
}

let name = '';
if (options.name) {
validateString(options.name, 'options.name');
name = StringPrototypeTrim(options.name);
}

// Set up the C++ handle for the worker, as well as some internal wiring.
this[kHandle] = new WorkerImpl(url,
env === process.env ? null : env,
options.execArgv,
parseResourceLimits(options.resourceLimits),
!!(options.trackUnmanagedFds ?? true));
!!(options.trackUnmanagedFds ?? true),
name);
if (this[kHandle].invalidExecArgv) {
throw new ERR_WORKER_INVALID_EXEC_ARGV(this[kHandle].invalidExecArgv);
}
Expand Down
8 changes: 7 additions & 1 deletion src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,17 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
Environment* env,
ThreadId thread_id,
const char* url) {
return GetInspectorParentHandle(env, thread_id, url, "");
}

NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
Environment* env, ThreadId thread_id, const char* url, const char* name) {
CHECK_NOT_NULL(env);
if (name == nullptr) name = "";
CHECK_NE(thread_id.id, static_cast<uint64_t>(-1));
#if HAVE_INSPECTOR
return std::make_unique<InspectorParentHandleImpl>(
env->inspector_agent()->GetParentHandle(thread_id.id, url));
env->inspector_agent()->GetParentHandle(thread_id.id, url, name));
#else
return {};
#endif
Expand Down
23 changes: 14 additions & 9 deletions src/inspector/worker_inspector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,20 @@ class WorkerStartedRequest : public Request {
uint64_t id,
const std::string& url,
std::shared_ptr<node::inspector::MainThreadHandle> worker_thread,
bool waiting)
bool waiting,
const std::string& name)
: id_(id),
info_(BuildWorkerTitle(id), url, worker_thread),
info_(BuildWorkerTitle(id, name), url, worker_thread),
waiting_(waiting) {}
void Call(MainThreadInterface* thread) override {
auto manager = thread->inspector_agent()->GetWorkerManager();
manager->WorkerStarted(id_, info_, waiting_);
}

private:
static std::string BuildWorkerTitle(int id) {
return "Worker " + std::to_string(id);
static std::string BuildWorkerTitle(int id, const std::string& name) {
return "[worker " + std::to_string(id) + "]" +
(name == "" ? "" : " " + name);
}

uint64_t id_;
Expand Down Expand Up @@ -57,11 +59,13 @@ ParentInspectorHandle::ParentInspectorHandle(
uint64_t id,
const std::string& url,
std::shared_ptr<MainThreadHandle> parent_thread,
bool wait_for_connect)
bool wait_for_connect,
const std::string& name)
: id_(id),
url_(url),
parent_thread_(parent_thread),
wait_(wait_for_connect) {}
wait_(wait_for_connect),
name_(name) {}

ParentInspectorHandle::~ParentInspectorHandle() {
parent_thread_->Post(
Expand All @@ -71,7 +75,7 @@ ParentInspectorHandle::~ParentInspectorHandle() {
void ParentInspectorHandle::WorkerStarted(
std::shared_ptr<MainThreadHandle> worker_thread, bool waiting) {
std::unique_ptr<Request> request(
new WorkerStartedRequest(id_, url_, worker_thread, waiting));
new WorkerStartedRequest(id_, url_, worker_thread, waiting, name_));
parent_thread_->Post(std::move(request));
}

Expand All @@ -97,9 +101,10 @@ void WorkerManager::WorkerStarted(uint64_t session_id,
}

std::unique_ptr<ParentInspectorHandle> WorkerManager::NewParentHandle(
uint64_t thread_id, const std::string& url) {
uint64_t thread_id, const std::string& url, const std::string& name) {
bool wait = !delegates_waiting_on_start_.empty();
return std::make_unique<ParentInspectorHandle>(thread_id, url, thread_, wait);
return std::make_unique<ParentInspectorHandle>(
thread_id, url, thread_, wait, name);
}

void WorkerManager::RemoveAttachDelegate(int id) {
Expand Down
14 changes: 7 additions & 7 deletions src/inspector/worker_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ class ParentInspectorHandle {
ParentInspectorHandle(uint64_t id,
const std::string& url,
std::shared_ptr<MainThreadHandle> parent_thread,
bool wait_for_connect);
bool wait_for_connect,
const std::string& name);
~ParentInspectorHandle();
std::unique_ptr<ParentInspectorHandle> NewParentInspectorHandle(
uint64_t thread_id, const std::string& url) {
return std::make_unique<ParentInspectorHandle>(thread_id,
url,
parent_thread_,
wait_);
uint64_t thread_id, const std::string& url, const std::string& name) {
return std::make_unique<ParentInspectorHandle>(
thread_id, url, parent_thread_, wait_, name);
}
void WorkerStarted(std::shared_ptr<MainThreadHandle> worker_thread,
bool waiting);
Expand All @@ -80,6 +79,7 @@ class ParentInspectorHandle {
std::string url_;
std::shared_ptr<MainThreadHandle> parent_thread_;
bool wait_;
std::string name_;
};

class WorkerManager : public std::enable_shared_from_this<WorkerManager> {
Expand All @@ -88,7 +88,7 @@ class WorkerManager : public std::enable_shared_from_this<WorkerManager> {
: thread_(thread) {}

std::unique_ptr<ParentInspectorHandle> NewParentHandle(
uint64_t thread_id, const std::string& url);
uint64_t thread_id, const std::string& url, const std::string& name);
void WorkerStarted(uint64_t session_id, const WorkerInfo& info, bool waiting);
void WorkerFinished(uint64_t session_id);
std::unique_ptr<WorkerManagerEventHandle> SetAutoAttach(
Expand Down
6 changes: 3 additions & 3 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -952,17 +952,17 @@ void Agent::SetParentHandle(
}

std::unique_ptr<ParentInspectorHandle> Agent::GetParentHandle(
uint64_t thread_id, const std::string& url) {
uint64_t thread_id, const std::string& url, const std::string& name) {
if (!parent_env_->should_create_inspector() && !client_) {
ThrowUninitializedInspectorError(parent_env_);
return std::unique_ptr<ParentInspectorHandle>{};
}

CHECK_NOT_NULL(client_);
if (!parent_handle_) {
return client_->getWorkerManager()->NewParentHandle(thread_id, url);
return client_->getWorkerManager()->NewParentHandle(thread_id, url, name);
} else {
return parent_handle_->NewParentInspectorHandle(thread_id, url);
return parent_handle_->NewParentInspectorHandle(thread_id, url, name);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/inspector_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Agent {

void SetParentHandle(std::unique_ptr<ParentInspectorHandle> parent_handle);
std::unique_ptr<ParentInspectorHandle> GetParentHandle(
uint64_t thread_id, const std::string& url);
uint64_t thread_id, const std::string& url, const std::string& name);

// Called to create inspector sessions that can be used from the same thread.
// The inspector responds by using the delegate to send messages back.
Expand Down
6 changes: 6 additions & 0 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,12 @@ NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
ThreadId child_thread_id,
const char* child_url);

NODE_EXTERN std::unique_ptr<InspectorParentHandle> GetInspectorParentHandle(
Environment* parent_env,
ThreadId child_thread_id,
const char* child_url,
const char* name);

struct StartExecutionCallbackInfo {
v8::Local<v8::Object> process_object;
v8::Local<v8::Function> native_require;
Expand Down
21 changes: 15 additions & 6 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ constexpr double kMB = 1024 * 1024;
Worker::Worker(Environment* env,
Local<Object> wrap,
const std::string& url,
const std::string& name,
std::shared_ptr<PerIsolateOptions> per_isolate_opts,
std::vector<std::string>&& exec_argv,
std::shared_ptr<KVStore> env_vars,
Expand All @@ -58,6 +59,7 @@ Worker::Worker(Environment* env,
exec_argv_(exec_argv),
platform_(env->isolate_data()->platform()),
thread_id_(AllocateEnvironmentThreadId()),
name_(name),
env_vars_(env_vars),
snapshot_data_(snapshot_data) {
Debug(this, "Creating new worker instance with thread id %llu",
Expand All @@ -82,8 +84,8 @@ Worker::Worker(Environment* env,
Number::New(env->isolate(), static_cast<double>(thread_id_.id)))
.Check();

inspector_parent_handle_ = GetInspectorParentHandle(
env, thread_id_, url.c_str());
inspector_parent_handle_ =
GetInspectorParentHandle(env, thread_id_, url.c_str(), name.c_str());

argv_ = std::vector<std::string>{env->argv()[0]};
// Mark this Worker object as weak until we actually start the thread.
Expand Down Expand Up @@ -264,11 +266,10 @@ size_t Worker::NearHeapLimit(void* data, size_t current_heap_limit,
}

void Worker::Run() {
std::string name = "WorkerThread ";
name += std::to_string(thread_id_.id);
std::string trace_name = "[worker " + std::to_string(thread_id_.id) + "]" +
(name_ == "" ? "" : " " + name_);
TRACE_EVENT_METADATA1(
"__metadata", "thread_name", "name",
TRACE_STR_COPY(name.c_str()));
"__metadata", "thread_name", "name", TRACE_STR_COPY(trace_name.c_str()));
CHECK_NOT_NULL(platform_);

Debug(this, "Creating isolate for worker with id %llu", thread_id_.id);
Expand Down Expand Up @@ -467,6 +468,7 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
}

std::string url;
std::string name;
std::shared_ptr<PerIsolateOptions> per_isolate_opts = nullptr;
std::shared_ptr<KVStore> env_vars = nullptr;

Expand All @@ -479,6 +481,12 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
url.append(value.out(), value.length());
}

if (!args[5]->IsNullOrUndefined()) {
Utf8Value value(
isolate, args[5]->ToString(env->context()).FromMaybe(Local<String>()));
name.append(value.out(), value.length());
}

if (args[1]->IsNull()) {
// Means worker.env = { ...process.env }.
env_vars = env->env_vars()->Clone(isolate);
Expand Down Expand Up @@ -589,6 +597,7 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
Worker* worker = new Worker(env,
args.This(),
url,
name,
per_isolate_opts,
std::move(exec_argv_out),
env_vars,
Expand Down
3 changes: 3 additions & 0 deletions src/node_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Worker : public AsyncWrap {
Worker(Environment* env,
v8::Local<v8::Object> wrap,
const std::string& url,
const std::string& name,
std::shared_ptr<PerIsolateOptions> per_isolate_opts,
std::vector<std::string>&& exec_argv,
std::shared_ptr<KVStore> env_vars,
Expand Down Expand Up @@ -99,6 +100,8 @@ class Worker : public AsyncWrap {
ExitCode exit_code_ = ExitCode::kNoFailure;
ThreadId thread_id_;
uintptr_t stack_base_ = 0;
// Optional name used for debugging in inspector and trace events.
std::string name_;

// Custom resource constraints:
double resource_limits_[kTotalResourceLimitCount];
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/worker-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { Session } = require('inspector');
const { parentPort } = require('worker_threads');

const session = new Session();

parentPort.once('message', () => {}); // Prevent the worker from exiting.

session.connectToMainThread();

session.on(
'NodeWorker.attachedToWorker',
({ params: { workerInfo } }) => {
// send the worker title to the main thread
parentPort.postMessage(workerInfo.title);
}
);
session.post('NodeWorker.enable', { waitForDebuggerOnStart: false });
31 changes: 31 additions & 0 deletions test/parallel/test-trace-events-worker-metadata-with-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const cp = require('child_process');
const fs = require('fs');
const { isMainThread } = require('worker_threads');

if (isMainThread) {
const CODE = 'const { Worker } = require(\'worker_threads\'); ' +
`new Worker('${__filename.replace(/\\/g, '/')}', { name: 'foo' })`;
const FILE_NAME = 'node_trace.1.log';
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
process.chdir(tmpdir.path);

const proc = cp.spawn(process.execPath,
[ '--trace-event-categories', 'node',
'-e', CODE ]);
proc.once('exit', common.mustCall(() => {
assert(fs.existsSync(FILE_NAME));
fs.readFile(FILE_NAME, common.mustCall((err, data) => {
const traces = JSON.parse(data.toString()).traceEvents;
assert(traces.length > 0);
assert(traces.some((trace) =>
trace.cat === '__metadata' && trace.name === 'thread_name' &&
trace.args.name === '[worker 1] foo'));
}));
}));
} else {
// Do nothing here.
}
2 changes: 1 addition & 1 deletion test/parallel/test-trace-events-worker-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (isMainThread) {
assert(traces.length > 0);
assert(traces.some((trace) =>
trace.cat === '__metadata' && trace.name === 'thread_name' &&
trace.args.name === 'WorkerThread 1'));
trace.args.name === '[worker 1]'));
}));
}));
} else {
Expand Down
22 changes: 22 additions & 0 deletions test/parallel/test-worker-name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const common = require('../common');
const fixtures = require('../common/fixtures');

common.skipIfInspectorDisabled();
common.skipIfWorker(); // This test requires both main and worker threads.

const assert = require('assert');
const { Worker, isMainThread } = require('worker_threads');

if (isMainThread) {
const name = 'Hello Thread';
const expectedTitle = `[worker 1] ${name}`;
const worker = new Worker(fixtures.path('worker-name.js'), {
name,
});
worker.once('message', common.mustCall((message) => {
assert.strictEqual(message, expectedTitle);
worker.postMessage('done');
}));
}