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

169
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
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