Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!