Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
NodeJs communication between 2 child process?

I'm trying to optimize my code because it takes some time to run. The main part that slows it down is starting up puppeteer and navigating to the site and logging in. After this step I would ask for users input to a folder location to upload files.

The puppeteer setup takes about 8-10 seconds. So i'm trying to run that in parallel with getting users input to save time.

I'm not sure what the best way to communicate between child process is. After puppeteer loads it needs the folder location to run the next steps. So after the input process is complete it should send the info to the puppeteer process.

What I've done is once the input process is complete I would use

process.send({type: "upload", data: inputData})

Then in the main process I would receive it and send the data to the puppeteer process like

Main process index.js

const input = fork("./app.js");
const upload = fork("./upload.js");

input.on("message", function (chunk) {
    const { type, data } = chunk;

    switch (type) {
        case "file":
            console.log(data);
            break;
        case "upload":
            upload.send(chunk);
            break;
        case "message":
            console.log(data);
            break;
        default:
            console.log(data);
            break;
    }
});

Is there an easier or more efficient way of communicating data between child process without having to send to to parent and then from there to the next child?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!