Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

fix: Return only one response for each request#15

Draft
TerryvanWalen wants to merge 1 commit into
mainfrom
fix/limit-request-to-one-response
Draft

fix: Return only one response for each request#15
TerryvanWalen wants to merge 1 commit into
mainfrom
fix/limit-request-to-one-response

Conversation

@TerryvanWalen

@TerryvanWalen TerryvanWalen commented Jun 21, 2024

Copy link
Copy Markdown

This should resolve the 2870 errors we received last week:

EXCEPTION
Cannot set headers after they are sent to the client
Problem Id: Error at new NodeError

@TerryvanWalen TerryvanWalen marked this pull request as ready for review June 21, 2024 10:37
Comment thread packages/cms/app.js
Comment on lines +297 to 304
try {
await fetchAllSites(req, res);
} catch (e) {
console.error('An error occurred fetching the site config:', e);
if (res) return res.status(500).json({error: 'An error occured fetching the sites data: ' + e});
}
req.forceRestart = true;
next();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to do an early return because we can only return one response to each request. Is the req.forceRestart doing something important?

The next() loads the next middleware, that middleware can emit another response.

@TerryvanWalen TerryvanWalen marked this pull request as draft June 24, 2024 08:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant