Is there a way to have a single MessageChannel in the main process with multiple tasks like the parentPort
I tried with
(async function () {
const channel = new MessageChannel()
channel.port1.on('message', (message) => {
console.log(message)
})
let a = 0
while (a < 10) {
piscina.runTask({ hello: `world${a}`, port: channel.port2 }, [channel.port2])
a++
}
})()
but it gets DataCloneError: MessagePort in transfer list is already detached
Is there a way to have a single MessageChannel in the main process with multiple tasks like the parentPort
I tried with
but it gets
DataCloneError: MessagePort in transfer list is already detached