openpodcast / api

OpenPodcast API server
https://openpodcast.dev
8 stars 2 forks source link

test of analytics throws error on server #102

Closed woolfg closed 1 year ago

woolfg commented 1 year ago

when running the test suite the following error is thrown on the server even though all tests are green

code: 'ERR_HTTP_HEADERS_SENT'
[1] }
[1] Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
mre commented 1 year ago

It's probably because of our middleware.

We're using middleware and call next() after sending the response. The middleware function may not try to send a response.

app.get('/path', (req, res, next) => {
  res.send('Hello, World!');
  next(); // Don't call next after sending a response
});

Maybe happens here, which is our error handler? https://github.com/openpodcast/api/blob/d9acef6bbed235bbf95fdee0c823bbaf356c4fb7/src/index.ts#L420

woolfg commented 1 year ago

will pop up again if still a problem.