Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest version of Parse Server.
Issue Description
This discussion started in #6423 (comment) so this is a standalone issue where we can discuss this in isolation (most text is just a copy from my original comment).
I stumbled upon PR #6423 since we're currently adopting Sentry error reporting for our backend. To use Sentry's errorHandler middleware we're required to set enableExpressErrorHandler to true. However, after PR #6423 was merged this also mean that the default Parse error handler is basically disabled.
I checked the history and found the PR that introduced this feature from the beginning (#4697). The original intention seems to have been quite different. Instead of replacing the default Parse error handler it just used next to let the error flow through subsequent middlewares, which would be optimal our use-case with Sentry.
So by merging this fix it also seems to have broken the intended behaviour. A way to solve this might be to introduce a "overrideParseErrorHandler" (naming suggestions greatly appreciated) config or similar, and restore the original behaviour.
A workaround is of course to copy the logic from the Parse error handler and use that as a middleware in our own application, but that's not optimal.