node/test/fixtures/worker-preload.js
James M Snell 360e8c842a
workers: fix spawning from preload scripts
Fix spawning nested worker threads from preload scripts and
warn about doing so.

Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: https://github.com/nodejs/node/issues/36531

PR-URL: https://github.com/nodejs/node/pull/37481
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2021-03-01 11:43:27 -08:00

10 lines
136 B
JavaScript

const {
Worker,
workerData,
threadId
} = require('worker_threads');
if (threadId < 2) {
new Worker('1 + 1', { eval: true });
}