Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixup! add a test
  • Loading branch information
debadree25 committed Feb 28, 2023
commit 2680a3e09e4808cf6af0cbae9ecedbd982b2029f
25 changes: 25 additions & 0 deletions test/parallel/test-worker-title-prefix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

const common = require('../common');
common.skipIfInspectorDisabled();
const assert = require('assert');
const { Worker, isMainThread } = require('worker_threads');

const { Session } = require('inspector');

if (isMainThread) {
const titlePrefix = 'Hello Thread ';
new Worker(__filename, {
workerData: 'Test Worker',
titlePrefix,
});

const session = new Session();
session.connect();
session.on('NodeWorker.attachedToWorker', ({ params: { workerInfo } }) => {
const id = workerInfo.id;
const expectedTitle = `${titlePrefix}Worker ${id}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello ThreadWorker just feels a bit odd (specifically, not having a space between the prefix and Worker). I would almost prefer a model like Worker {id} [label] ... e.g. Worker 1 [Hello Thread]. Consider this non-blocking tho.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i am updating the name formation as per this #46832 (comment)

assert.strictEqual(workerInfo.title, expectedTitle);
});
session.post('NodeWorker.enable', { waitForDebuggerOnStart: false });
}