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

167
Vistas
ExpressJs HTTP Streaming make me run out of disk space

My express server

app.get('/data', (_, res) => {
    const interval = setInterval(
        () => res.write(`${Math.random().toString()}\n`),
        1000
    );
    res.on('close', () => {
        clearInterval(interval);
        res.end();
    });
});

My client-side

const res = await fetch('/data')
const reader = res.body.getReader()
reader.read().then(data => {
    const { value, done} = data;
    console.log(value);
})

Everything working fine, data is streaming every second and log. However, whenever I refresh page or close it, the server-side start to filling up my disk space at rate of 100MB/second.

Best of my guess is that one single random number can't match with 100MB.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your client-side code reads only one chunk of the data from the server so that the server-side buffer fills up every second (although not by 100MB?). Does the problem still occur if you replace the client-side code with

const res = await fetch('/data');
const reader = res.body.getReader();
while (!await reader.read().then(function({value, done}) {
  console.log(value);
  return done;
}));

?

about 4 years ago · Juan Pablo Isaza Denunciar

0

I have tried again on different machines and I can conclude that the reason for this is Google Cloud Shell's bugs. It has nothing to do with Docker or ExpressJs.

about 4 years ago · Juan Pablo Isaza Denunciar
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