diff options
author | James M Snell <jasnell@gmail.com> | 2021-02-22 23:58:47 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2021-03-02 16:08:53 +0300 |
commit | d93137b2a9e215f8715bfab39d04525da4b0842c (patch) | |
tree | 432787b1e656b13dd8d9c21be657d32617bd9f94 /test | |
parent | cbfc6b1692c4670625adb7295996f1ba3866de21 (diff) |
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>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/worker-preload.js | 9 | ||||
-rw-r--r-- | test/parallel/test-preload-worker.js | 10 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/fixtures/worker-preload.js b/test/fixtures/worker-preload.js new file mode 100644 index 00000000000..6e5c4a31d2f --- /dev/null +++ b/test/fixtures/worker-preload.js @@ -0,0 +1,9 @@ +const { + Worker, + workerData, + threadId +} = require('worker_threads'); + +if (threadId < 2) { + new Worker('1 + 1', { eval: true }); +} diff --git a/test/parallel/test-preload-worker.js b/test/parallel/test-preload-worker.js new file mode 100644 index 00000000000..3e9134b470c --- /dev/null +++ b/test/parallel/test-preload-worker.js @@ -0,0 +1,10 @@ +'use strict'; + +const common = require('../common'); +const fixtures = require('../common/fixtures'); +const worker = fixtures.path('worker-preload.js'); +const { exec } = require('child_process'); +const kNodeBinary = process.argv[0]; + + +exec(`"${kNodeBinary}" -r "${worker}" -pe "1+1"`, common.mustSucceed()); |