kartikk221 / live-directory

A Simple-To-Use Dynamic Template Content Manager For Webservers
MIT License
12 stars 5 forks source link

LiveDirectory for static assets in Hyper-Express sometimes does leaves connection hanging #1

Closed MichaelJCole closed 2 years ago

MichaelJCole commented 2 years ago

Hello, I am trying to use LiveDirectory to serve static assets with Hyper-Express like this:

const LiveAssets = new LiveDirectory({ path: './public' });
app.get('/*',(req, res) => {
  const found = LiveAssets.get(req.path);
  if (!found) return res.status(404).send();
  res.type(found.extension).send(found.buffer);
});

I am working on integrating passportjs with hyper-express based on the passportjs example I forked here:

https://github.com/MichaelJCole/hyper-express-sessions-passport-local

When I start the server and reload in chrome, almost always the server connections hang on some of the static assets. If I reload 20ish times, the assets server just fine.

To reproduce, try the master branch. I'm using node 14.18.1. Firefox 95.0.2.

image

Am I using this wrong? Thank you!

kartikk221 commented 2 years ago

The snippet you posted above looks fine so there is likely some problem in one of your middlewares which are not continuing their execution. I would say look through all of your middlewares and check to see that you are calling the next() parameter callback or resolving any await promises inside of async middlewares. To narrow down to which middleware is causing the problem, try commenting out the use() calls to each middleware until the problem is resolved.

MichaelJCole commented 2 years ago

Hi Kartik, I just moved this to: https://github.com/kartikk221/hyper-express/issues/42. Ok, I'll try that out and comment there. Thank you!