Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda