PR-URL: https://github.com/nodejs/node/pull/62020 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
17 lines
487 B
JavaScript
17 lines
487 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker, threadName, workerData } = require('worker_threads');
|
|
|
|
const name = 'test-worker-thread-name';
|
|
|
|
if (workerData?.isWorker) {
|
|
assert.strictEqual(threadName, name);
|
|
} else {
|
|
const w = new Worker(__filename, { name, workerData: { isWorker: true } });
|
|
assert.strictEqual(w.threadName, name);
|
|
w.on('exit', common.mustCall(() => {
|
|
assert.strictEqual(w.threadName, null);
|
|
}));
|
|
}
|