http-delayed-response icon indicating copy to clipboard operation
http-delayed-response copied to clipboard

Delayed response keeps connection open?

Open PanMan opened this issue 9 years ago • 1 comments

Hi! Could it be the connection isn't closed properly after the response? I'm using this on Heroku, to keep the connection open when generating a PDF. The code is below. But recently it started throwing H15 desc="Idle connection" errors. Any pointers?

    res.setHeader('content-type', 'text/html');
    res.write('Creating PDf... Wait for it...');

    var delayed = new DelayedResponse(req, res);
    delayed.start()

    makeFullPdf( function(pdfurl){
      console.log('PDF ready');
      var html='<br/><A HREF="'+pdfurl+'"> Open PDF</A>';
      html+='<script>window.location="'+pdfurl+'"; </script>'; //JS as we can't send headers at this point
      delayed.end(null, html);
      res.end();
    })

Thanks!

PanMan avatar Apr 25 '16 14:04 PanMan

Have your code been running successfully before? If so, for how long? I don't see anything wrong with your code sample, except that you close the response twice (delayed.end will close the response).

extrabacon avatar Apr 25 '16 18:04 extrabacon