Answer the question
In order to leave comments, you need to log in
Is it possible to pass a promise or a function to a child process?
Is it possible to pass a promise or a function to a child process?
PS It seems to me that this can not be done, but suddenly.
const { fork } = require('child_process');
const child = fork('./myModule');
child.send(() => {
return Promise.resolve({})
})
//in myModule
process.on('message', (func) => {
func()
.then(res => {
process.send(res)
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question