From 9b4d1576df441bc242d1367496f6ec446df9f468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Tue, 4 Aug 2026 15:48:59 +0200 Subject: [PATCH] test: avoid worker in shared value conveyor test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Joyee Cheung PR-URL: https://github.com/nodejs/node/pull/65161 Reviewed-By: Antoine du Hamel Reviewed-By: Richard Lau --- ...test-experimental-shared-value-conveyor.js | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) 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');