Skip to content

Got error - The conditional request failed #124

@jacklam718

Description

@jacklam718

Hi @adrai
I'm using dynamodb. I can save events by the commit method but then I call commit for a exists stream then I got this error The conditional request failed

for example:

first time will be success

getEventStream (aggregateId: string){
  eventStore.getEventStream({
    aggregateId: '123',
    aggregate: 'Test',
    context: 'Test'
  }, (err, stream) => {
    if (err) return
    
    stream.addEvents([{
      type: 'ACCOUNT_CREATED',
      balance: 0,
    }]);
    stream.commit();
  });
}

second time will be fail - "The conditional request failed"

getEventStream (aggregateId: string){
  eventStore.getEventStream({
    aggregateId: '123',
    aggregate: 'Test',
    context: 'Test'
  }, (err, stream) => {
    if (err) return
    
    stream.addEvents([{
      type: 'DEPOSITED',
      amount: 200,
      balance: 200,
    }]);
    stream.commit();
  });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions