ArkerLabs / event-sourcing-nestjs

NestJS module for implementing Event Sourcing
224 stars 47 forks source link

When trying to upgrade nestjs/cqrs version to latest (8.0.5), eventPublishers no longer seem to be working #23

Open alfQontrol opened 2 years ago

alfQontrol commented 2 years ago

Hello,

We are trying to find an event sourcing solution that would fit our business requirements. Currently, we are considering using the NestJS implementation of CQRS on its latest version. To integrate your library to our project, we tried first the corresponding example project, which would work just perfectly (Hero Killed, then other eventHandler & sagas were triggered) Unfortunately, just by upgrading the version of nestjs/cqrs version in the package.json, things would break silently; initial event seems to be published, but no trigger of any related EventHandler. This issue should be easily reproduced by checking out the above mentioned project, and by upgrading the cqrs library version.

Any idea of how to solve this issue ?

Thanks a lot !

esalu commented 2 years ago

try with this solution autoCommit = true

const hero = this.publisher.mergeObjectContext(
  await this.repository.findOneById(id),
);
hero.autoCommit = true;
hero.create(data, { user });
//hero.commit();
ashutoshadaptivecode commented 1 year ago

Hey @esalu, The above alternative seems to be working but again the autoCommit will be not suitable for every scenario . is there any other way we can able to fix the hero.commit() part ?