-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fail fast on missing event type #77
Comments
As a counterpoint from a lurker/chicken, in Equinox the default behaviour (when building state) is to not throw or log about this kind of a situation - the thinking being that there are many common cases where you want to ignore some event types:
Obviously if you introduce a new financial instrument in your system and it does not consider the new For projections scenarios, I can't imagine anyone wanting logging or exceptions as you're typically white-listing a subset of events I'd be interested to hear your thoughts as to whether that makes you reconsider or double down... Would a hook that lets you log or throw in the case of an unknown event type address your desire? |
"Stops working" means what exactly? Subscriptions ignore unknown event types by default I made quite a few improvements for detecting unregistered event types upfront. Eventuous will throw and fail on startup in the following scenarios:
|
I might be wrong though. I think I started it, but it might not be 100% done. But, you get the idea. When using pattern matching in |
If you can explain what exactly fails and should throw (and doesn't) - I can look closer. Then again, if the database has events that aren't available in the application - it will always be failing at runtime. |
The app service results It might be mitigated quite simply by checking the result explicitly with |
It is my code which stops working. In this particular case I was reading and projecting events, and noticed the projector stopped long before reaching the end. This would probably be a less of a problem if we started out with Eventuous, but we didn't. So we have a mix of old projectors in there. Investigating further, I noticed that in this case it is the My problem with this is because of no exception, we got no notification of anything wrong. I decided to have a look at the source code of I see problems with this:
An empty |
Try this from the latest alpha: public static IServiceCollection AddApplicationService<T, TAggregate, TState, TId>(
this IServiceCollection services,
bool throwOnError = false
) |
I can't force you to do that, but it's documented https://eventuous.dev/docs/application/app-service/#result Also, if you add tracing, you will see it right away. |
Is it possible without the dependency container? |
Yes, just look at the code of that extension. You need to wrap your app service to a |
@thomaseyde any feedback? |
I will look into it. I see that the case isn't about not throwing, but that I didn't understand how to catch the error. Now that I do, I can do something about it. |
This is related to #4
Eventuous silently stop working when an event type is not registered, which makes it very hard to figure out why things aren't working.
Today I discovered we have obsolete events in our database, and we have managed to do the incredible stupid thing which is to delete or rename those events in our code base. This took us a few hours of debugging and added logging, and even then the discovery was by chance: We happened to log the result of
ApplicationService.Handle()
which we then could see contained an error message.It would have been so much easier and faster if an exception was thrown instead.
Faster feedback for new developers would guide us in the right direction faster. Swallowed exceptions have a too high risk of leaving the system in an invalid state.
The text was updated successfully, but these errors were encountered: