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

Stream subscription returns links to deleted events when ResolveLinkTos is set to true #152

Open
alexeyzimarev opened this issue Aug 19, 2021 · 2 comments

Comments

@alexeyzimarev
Copy link
Member

The ResolvedEvent.Event property is not nullable, so we assume that the property value is never null.

However, a catch-up subscription to a projected stream (i.e. category stream) with links to deleted events in it, delivers events to the subscriber where Event is null.

Steps to reproduce:

  • Produce events to multiple streams for the same category
  • Delete some of those streams
  • Create a catch-up subscription to the category stream
  • Try to get the Event and deserialise its payload without checking if Event is null as it is not a nullable property
  • Observe NullReferenceException when the subscription hits the first deleted event

I have a test in Eventuous, which reproduces the issue, so I can be sure that Eventuous can handle this properly.

Here is the test: https://github.com/Eventuous/eventuous/blob/26f3750da676b3ab85bb8e2f6be8934a2e045c04/test/Eventuous.Tests.EventStore/StreamSubscriptionTests.cs#L33

Here is the workaround:
https://github.com/Eventuous/eventuous/blob/26f3750da676b3ab85bb8e2f6be8934a2e045c04/src/Eventuous.Subscriptions.EventStoreDB/StreamSubscription.cs#L114-L124

@alexeyzimarev
Copy link
Member Author

I believe it can be handled in two ways:

  • Breaking change: if the event cannot be resolved, don't call the handler
  • Non-breaking change, but weird behaviour: mark Event as nullable

Note that other clients might handle the case differently. For example, the NodeJS client has the event property marked as nullable.

@Mousaka
Copy link

Mousaka commented Jan 11, 2022

I would opt for the first suggestion. It's very confusing to have a type named ResolvedEvent but you are not able to assume that it is actually Resolved.
EDIT: Alternatively, change the name of the type to something that makes sense.

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

No branches or pull requests

2 participants