worker: add worker name to report
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 3m3s
Linters / lint-sh (push) Failing after 1m25s
Linters / lint-codeowners (push) Failing after 56s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-js-and-md (push) Successful in 13m25s
Coverage Linux / coverage-linux (push) Failing after 2m55s
Test and upload documentation to artifacts / build-docs (push) Failing after 1m53s
Linters / lint-addon-docs (push) Successful in 2m24s
Linters / format-cpp (push) Has been skipped
Linters / lint-cpp (push) Successful in 3m46s
Linters / lint-py (push) Successful in 2m44s
Linters / lint-yaml (push) Successful in 2m33s
Linters / lint-readme (push) Successful in 1m25s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 53s

PR-URL: https://github.com/nodejs/node/pull/58935
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
This commit is contained in:
theanarkh 2025-08-12 18:25:12 +08:00 committed by GitHub
parent ad292b8e4f
commit abccbb438b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View file

@ -233,11 +233,11 @@ static void WriteNodeReport(Isolate* isolate,
size_t expected_results = 0;
env->ForEachWorker([&](Worker* w) {
expected_results += w->RequestInterrupt([&](Environment* env) {
expected_results += w->RequestInterrupt([&, w = w](Environment* env) {
std::ostringstream os;
GetNodeReport(
env, "Worker thread subreport", trigger, Local<Value>(), os);
std::string name =
"Worker thread subreport [" + std::string(w->name()) + "]";
GetNodeReport(env, name.c_str(), trigger, Local<Value>(), os);
Mutex::ScopedLock lock(workers_mutex);
worker_infos.emplace_back(os.str());

View file

@ -62,6 +62,7 @@ class Worker : public AsyncWrap {
bool is_stopped() const;
const SnapshotData* snapshot_data() const { return snapshot_data_; }
bool is_internal() const { return is_internal_; }
std::string_view name() const { return name_; }
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
static void CloneParentEnvVars(

View file

@ -13,7 +13,7 @@ async function basic() {
parentPort.once('message', () => {
/* Wait for message to stop the Worker */
});
`, { eval: true });
`, { eval: true, name: 'hello' });
await once(w, 'online');
@ -22,7 +22,9 @@ async function basic() {
assert.strictEqual(report.workers.length, 1);
helper.validateContent(report.workers[0]);
assert.strictEqual(report.workers[0].header.threadId, w.threadId);
assert.strictEqual(report.workers[0].header.event,
'Worker thread subreport [hello]',
report.workers[0].header.event);
w.postMessage({});
await once(w, 'exit');