juicycleff / nestjs-event-store

NestJS CQRS module for EventStore.org. It requires @nestjs/cqrs

Home Page:https://xraph.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Catchup Checkpoint Not Updating

tadejgasparovic opened this issue · comments

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);
});

@tadejgasparovic looking into it

Fixed, thanks for raising this issue