express-stream icon indicating copy to clipboard operation
express-stream copied to clipboard

Browser hangs if pug templates are used

Open rajasegar opened this issue 4 years ago • 4 comments

Have you checked with pug, I think there may be some problem when using res.end() and the response is not flushed with the last chunk, the browser hangs for a long time without any error and the last chunk is not sent to the browser.

rajasegar avatar Apr 17 '21 10:04 rajasegar

This is my code

stream.useAllAutoTags(true);
stream.streamBefore('_header');
stream.streamAfter('_footer');

app.get('/', stream.stream(), (req,res) => {
  res.stream('index');
  res.end
});

rajasegar avatar Apr 17 '21 10:04 rajasegar

I haven't touched this project in years, so I'm not as familiar as I once was. That said, I did notice a difference between your code snippet and the readme. You may need to update your code snippet by replacing res.end with res.close();.

jpodwys avatar Apr 20 '21 18:04 jpodwys

I am afraid that won't work due to the res.close method not available anymore Related to #11

rajasegar avatar Apr 21 '21 03:04 rajasegar

Oh thanks, you're right. I did notice that your code snippet doesn't call res.end as a function. Can you double check that you're calling res.end(); with parenthesis?

jpodwys avatar Apr 21 '21 16:04 jpodwys