Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,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());
Expand Down
1 change: 1 addition & 0 deletions src/node_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions test/report/test-report-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');
Expand Down
Loading