moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.11k stars 580 forks source link

errorHandlerMiddleware prevents propagation of errors to the Transporter #991

Closed JordanPawlett closed 1 year ago

JordanPawlett commented 3 years ago

I recently made a pull-request to handle proper propagation of whether or not the event was handled successfully to the Transporter. https://github.com/moleculerjs/moleculer/pull/984

However, the errorHandlerMiddleware catches all errors, meaning the Transit layer will always resolve true for the event messageHandler. Even if you define a global error handler and throw an error, this would still be caught at the bottom of this function.

I suggest we either allow event handlers to throw errors now PR 984 has been merged, or we make the ability to throw errors in event handlers configurable.

JordanPawlett commented 3 years ago

I can get around this issue by overriding the error-handler middleware and removing the final catch, but i think this should be solved inside the framework.