node/test/parallel/test-worker-name.js
theanarkh 9ec68afdc5
Some checks failed
Coverage Windows / coverage-windows (push) Waiting to run
Coverage Linux / coverage-linux (push) Failing after 1m29s
Coverage Linux (without intl) / coverage-linux-without-intl (push) Failing after 1m29s
Linters / lint-cpp (push) Successful in 3m46s
Test and upload documentation to artifacts / build-docs (push) Failing after 5m35s
Linters / lint-py (push) Successful in 2m40s
Linters / lint-sh (push) Failing after 1m25s
Linters / lint-addon-docs (push) Successful in 2m20s
Linters / format-cpp (push) Has been skipped
Linters / lint-yaml (push) Successful in 2m13s
Linters / lint-codeowners (push) Failing after 57s
Linters / lint-pr-url (push) Has been skipped
Linters / lint-readme (push) Successful in 1m26s
Notify on Push / Notify on Force Push on `main` (push) Has been skipped
Notify on Push / Notify on Push on `main` that lacks metadata (push) Has been skipped
Scorecard supply-chain security / Scorecard analysis (push) Failing after 53s
Linters / lint-js-and-md (push) Failing after 19m26s
worker: fix worker name with \0
PR-URL: https://github.com/nodejs/node/pull/59214
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2025-08-13 13:53:24 +00:00

29 lines
639 B
JavaScript

'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
common.skipIfInspectorDisabled();
const {
Worker,
isMainThread,
} = require('worker_threads');
if (!isMainThread) {
common.skip('This test only works on a main thread');
}
const assert = require('assert');
if (isMainThread) {
const name = 'Hello\0Thread';
const expectedTitle = `[worker 1] ${name}`;
const worker = new Worker(fixtures.path('worker-name.js'), {
name,
});
worker.once('message', common.mustCall((message) => {
assert.strictEqual(message, expectedTitle);
worker.postMessage('done');
}));
}