mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 00:20:08 +01:00
worker: add worker name to report
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:
parent
ad292b8e4f
commit
abccbb438b
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user