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

228
Vistas
How do I use child process spawn to run curl command?

I've been trying to download a HAR file from saucelabs using the exec command, but I get this error when it downloads too much data:

RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded

I've seen that child_process spawn is used instead for larger files, but I haven't managed to get it to work with all the parameters I am sending. Also I couldn't figure out how to return the downloaded data and store as a variable with spawn. Is anybody able to show me how to use spawn to get the data, and how to save that data into a variable for further processing.

Thanks

async getNetworkRequests (jobId) {
const harFile = await new Promise((resolve, reject) => {
  exec(`curl -u "${process.env.SAUCE_USER}:${process.env.SAUCE_KEY}" --location --compressed --request GET 'https://api.eu-central-1.saucelabs.com/rest/v1/${process.env.SAUCE_USER}/jobs/${jobId}/assets/network.har'`, (error, stdout) => {
    if (error) {
      console.log(`Error message: ${error}`)
      reject(error)
    }
    resolve(stdout)
  })
})
return harFile
}

I've made some progress with spawn, but I am unable to get the data out of the stdout function:

async getNetworkRequests (jobId) {
const spawnProcess = spawn('/bin/sh', ['-c', `curl -u "${process.env.SAUCE_USER}:${process.env.SAUCE_KEY}" --location --compressed --request GET 'https://api.eu-central-1.saucelabs.com/rest/v1/${process.env.SAUCE_USER}/jobs/${jobId}/assets/network.har'`])

const output
spawnProcess.stdout.on('data', data => {
  output = data.toString()
  })
console.log(output) // This returns undefined
}
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