Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok so I am trying to send 2 objects to a worker thread ( one string and one array), the issue is that I can only send one object thru workerData.

What I have tried:

So I have tried creating a second constant called workerData2 and send an object thru it like this:
const { workerData, workerData2, parentPort } = require('worker_threads')

const worker = new Worker('./worker.js', {workerData: array[channel], workerData2: 'test'});

but workerData2 is always undefined
Posted
Updated 20-Sep-22 2:32am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900