Commit 9b4d1576df4 for nodejs
commit 9b4d1576df441bc242d1367496f6ec446df9f468
Author: Michaël Zasso <targos@protonmail.com>
Date: Tue Aug 4 15:48:59 2026 +0200
test: avoid worker in shared value conveyor test
V8 no longer supports JSON.parse on worker isolates while the shared
string table is enabled. Since --harmony-struct enables that table and
Node workers parse process.config during bootstrap,
use direct MessageChannel instead of a worker.
Signed-Off-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65161
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <richard.lau@ibm.com>
diff --git a/test/parallel/test-experimental-shared-value-conveyor.js b/test/parallel/test-experimental-shared-value-conveyor.js
index 123e212bd1d..b4e3cb2f1db 100644
--- a/test/parallel/test-experimental-shared-value-conveyor.js
+++ b/test/parallel/test-experimental-shared-value-conveyor.js
@@ -1,27 +1,23 @@
'use strict';
const common = require('../common');
const assert = require('assert');
-const { Worker, parentPort } = require('worker_threads');
+const { MessageChannel } = require('worker_threads');
const { spawnSyncAndAssert } = require('../common/child_process');
if (process.env.TEST_CHILD_PROCESS === '1') {
- // Do not use isMainThread so that this test itself can be run inside a Worker.
- if (!process.env.HAS_STARTED_WORKER) {
- process.env.HAS_STARTED_WORKER = 1;
- const m = new globalThis.SharedArray(16);
+ // --harmony-struct implies --shared-string-table. V8 currently does not
+ // support JSON.parse in worker isolates with that flag, and Node workers
+ // parse process.config during bootstrap.
+ const m = new globalThis.SharedArray(16);
+ const { port1, port2 } = new MessageChannel();
- const worker = new Worker(__filename);
- worker.once('message', common.mustCall((message) => {
- assert.strictEqual(message, m);
- }));
+ port1.once('message', common.mustCall((message) => {
+ assert.strictEqual(message, m);
+ port1.close();
+ port2.close();
+ }));
- worker.postMessage(m);
- } else {
- parentPort.once('message', common.mustCall((message) => {
- // Simple echo.
- parentPort.postMessage(message);
- }));
- }
+ port2.postMessage(m);
} else {
if (process.config.variables.v8_enable_pointer_compression === 1) {
common.skip('--harmony-struct cannot be used with pointer compression');