bmavity / ges-client

A node.js client library for (Get) Event Store
Other
30 stars 9 forks source link

maxRecordCount generates an error when reading events #59

Open rehia opened 8 years ago

rehia commented 8 years ago

Hi,

I was trying to wrap ges-client in a repository in my code. And I wanted to query every single events of a stream to reload my aggregate state. So as the API needs us to provide a start and count, I provided 0 and client.maxRecordCount. But my test was failing and I had this as a log:

{ Status: 'Error',
  Events: [],
  NextEventNumber: -1,
  LastEventNumber: -1,
  IsEndOfStream: true }

For some reason, I tried to use a different value for the property count. And after some dichotomy, I finally found that when count is above 4096, I get the same error. But when count is lower than 4096 or equal, then I get my events. Here are my events:

[ { Event: 
     { EventStreamId: 'TestStream-1',
       EventId: 'cb0a92bb-ae66-492f-901e-f259f7b38d88',
       EventNumber: 50,
       EventType: 'TestStream',
       Data: <Buffer 7b ...>,
       Metadata: <Buffer 7b ...>,
       IsJson: true,
       Created: '635881237258614740',
       CreatedEpoch: '1452526925861' },
    IsResolved: false,
    Link: null,
    OriginalEvent: 
     { EventStreamId: 'TestStream-1',
       EventId: 'cb0a92bb-ae66-492f-901e-f259f7b38d88',
       EventNumber: 50,
       EventType: 'TestStream',
       Data: <Buffer 7b ...>,
       Metadata: <Buffer 7b ...>,
       IsJson: true,
       Created: '635881237258614740',
       CreatedEpoch: '1452526925861' },
    OriginalEventNumber: 50,
    OriginalPosition: null,
    OriginalStreamId: 'TestStream-1' } ]

Any idea on what's happening ?

I used EventStore v3.4.

bmavity commented 8 years ago

That's weird, I have no idea off the top of my head. I will take a look in the next day or two.

rehia commented 8 years ago

ok thanks. As long as I'm using eventstore in a docker container, I'll try to test with a previous version (3.0.5).

rehia commented 8 years ago

Yes, I confirm there's a change between 3.0.5 (at least) and 3.4. After relaunching my test on a 3.0.5, here are my logs:

{ start: 0, count: 2147483647 }
[ { Event: 
     { EventStreamId: 'TestStream-1',
       EventId: '4b9d6dfc-824d-472c-9a92-4de9ce5ca328',
       EventNumber: 0,
       EventType: 'TestStream',
       Data: <Buffer 7b...>,
       Metadata: <Buffer 7b...>,
       IsJson: true,
       Created: '635881260622658580',
       CreatedEpoch: '1452529262265' },
    IsResolved: false,
    Link: null,
    OriginalEvent: 
     { EventStreamId: 'TestStream-1',
       EventId: '4b9d6dfc-824d-472c-9a92-4de9ce5ca328',
       EventNumber: 0,
       EventType: 'TestStream',
       Data: <Buffer 7b...>,
       Metadata: <Buffer 7b...>,
       IsJson: true,
       Created: '635881260622658580',
       CreatedEpoch: '1452529262265' },
    OriginalEventNumber: 0,
    OriginalPosition: null,
    OriginalStreamId: 'TestStream-1' } ]
gregoryyoung commented 8 years ago

This is because you should page for large streams not just try to issue everything in one request.

On Mon, Jan 11, 2016 at 5:55 PM, Jérôme Avoustin notifications@github.com wrote:

Yes, I confirm there's a change between 3.0.5 (at least) and 3.4. After relaunching my test on a 3.0.5, here are my logs:

{ start: 0, count: 2147483647 } [ { Event: { EventStreamId: 'TestStream-1', EventId: '4b9d6dfc-824d-472c-9a92-4de9ce5ca328', EventNumber: 0, EventType: 'TestStream', Data: <Buffer 7b...>, Metadata: <Buffer 7b...>, IsJson: true, Created: '635881260622658580', CreatedEpoch: '1452529262265' }, IsResolved: false, Link: null, OriginalEvent: { EventStreamId: 'TestStream-1', EventId: '4b9d6dfc-824d-472c-9a92-4de9ce5ca328', EventNumber: 0, EventType: 'TestStream', Data: <Buffer 7b...>, Metadata: <Buffer 7b...>, IsJson: true, Created: '635881260622658580', CreatedEpoch: '1452529262265' }, OriginalEventNumber: 0, OriginalPosition: null, OriginalStreamId: 'TestStream-1' } ]

— Reply to this email directly or view it on GitHub https://github.com/bmavity/ges-client/issues/59#issuecomment-170616673.

Studying for the Turing test

bmavity commented 8 years ago

I'm going to leave this open to remind myself to add some documentation and hardcode the max in the api so it doesn't cause an error.

The solution for now, as Greg says, is to page through the streams.