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

SubscribeToStreamAsync will start with the next event after a given position #80

Closed
alexeyzimarev opened this issue Oct 15, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@alexeyzimarev
Copy link
Member

alexeyzimarev commented Oct 15, 2020

Describe the bug
SubscribeToStreamAsync with StreamPosition.Start will start from the second event in the stream

When subscribing from StreamPosition.Start, the first event delivered to eventAppeared will be the second event in the stream.

To Reproduce
Steps to reproduce the behavior:

  1. Append 10 events to the stream
  2. Subscribe to the same stream from Start
  3. Get nine events back

Expected behavior
Subscription delivers all events when using StreamPosition.Start.

Actual behavior
Subscription starts with the second event in the stream.

EventStore details

  • EventStore server version: 20.6.1

  • Operating system: macOS

  • EventStore client version (if applicable): 20.6.1

Additional context
https://github.com/alexeyzimarev/EsdbSubscriptionBug

@alexeyzimarev alexeyzimarev added the bug Something isn't working label Oct 15, 2020
@alexeyzimarev
Copy link
Member Author

Following @thefringeninja advice, the workaround for reading from the start is to use the overload without the position. It indeed starts from the beginning of the stream.

@alexeyzimarev
Copy link
Member Author

Updated the description.

@kaancfidan
Copy link

We have experienced this issue as well. Since we needed to also use a starting position in some cases we had to use the parameterless overload when a starting point is not specified and subtract 1 and use the bugged overload otherwise.

Needless to say, we would appreciate if this bug is fixed soon as it's a fundamental problem in gRPC client.

@thefringeninja
Copy link
Contributor

This is by design - subscribing is an exclusive operation. If you have no checkpoint, please user the overload that does not take a StreamPosition.

https://developers.eventstore.com/clients/dotnet/generated/v20.6.1/subscribing-to-streams/#subscribing-to-a-stream

@kaancfidan
Copy link

This is by design - subscribing is an exclusive operation. If you have no checkpoint, please user the overload that does not take a StreamPosition.

https://developers.eventstore.com/clients/dotnet/generated/v20.6.1/subscribing-to-streams/#subscribing-to-a-stream

I don't think off-by-one errors are by design and the behavior is different than the old TCP client.

@dariogriffo
Copy link

This is extremely confusing and should be properly documented. Wuth the concept of start as a position is natural to think the start of the stream is the event number 0, not whatever the underlying limitation of the implementation of the event store.
Also this adds overhead on every client that consumes the library:

If(we-dont-have-processed-events)
    Subscribe()
else
    Subscribe(position)

Is way more natural just do

var lastPosition = GetLastPosition()
Subscribe (lastPosition)

@ylorph
Copy link
Contributor

ylorph commented Mar 2, 2022

this has been fixed in version 22.0.0 of the client,
you can use FromAll.Start, FromStream.Start to achieve the desired behaviour.
More details in this PR #188

@ylorph ylorph closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants