Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda