Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable global error-handler again + some error-logging improvements #462

Merged
merged 1 commit into from
Nov 13, 2023

Conversation

fcaps
Copy link
Collaborator

@fcaps fcaps commented Nov 12, 2023

The global error-handler was disabled due some missing parameters (god knows i like this kind of magic).
Improved the logs to be more "production" friendly.
image

Comment on lines +327 to +329
if (res.headersSent) {
return next(err);
}
Copy link
Member

Choose a reason for hiding this comment

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

What does this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

there is an issue if the error is thrown after the server already sent the http-header, in this case it's better to let express handle the error, see https://expressjs.com/en/guide/error-handling.html
There are some pending issues with the general approach.. how to handle errors if the caller expects json, js etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if you missed it, this function was never called (thus no error handling on production) bc. of express expecting 4 parameters:
Define error-handling middleware functions in the same way as other middleware functions, except error-handling functions have four arguments instead of three: (err, req, res, next)

@fcaps fcaps requested a review from Brutus5000 November 13, 2023 20:05
@Brutus5000 Brutus5000 merged commit d7ccb9b into FAForever:develop Nov 13, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants