mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

PR-URL: https://github.com/nodejs/node/pull/59213 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
18 lines
506 B
JavaScript
18 lines
506 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);
|
|
process.exit(0);
|
|
} 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);
|
|
}));
|
|
}
|