juicycleff / nestjs-event-store

NestJS CQRS module for EventStore.org. It requires @nestjs/cqrs
https://xraph.com
MIT License
199 stars 29 forks source link

Catchup Checkpoint Not Updating #7

Closed tadejgasparovic closed 4 years ago

tadejgasparovic commented 4 years ago

When using a catchup subscription with a store for persisting checkpoints the store only gets read from on start and never written to. This occurs because _subscription doesn't have a type property. https://github.com/juicycleff/nestjs-event-store/blob/master/src/lib/event-store.ts#L285

Solution: Check the constructor name instead of type property.

Currently, this shim works for me.

const _onEvent = Reflect.get(EventStore.prototype, 'onEvent');
Reflect.set(EventStore.prototype, 'onEvent', async function(_sub, event) {
    console.log(_sub.constructor.name === 'EventStoreStreamCatchUpSubscription'); // true
    return _onEvent.call(this, Object.assign(_sub, { type: 'catch' }), event);
});
juicycleff commented 4 years ago

@tadejgasparovic looking into it

juicycleff commented 4 years ago

Fixed, thanks for raising this issue