pub-sub-api-node-client icon indicating copy to clipboard operation
pub-sub-api-node-client copied to clipboard

Events out of order

Open brodymccrone4 opened this issue 1 year ago • 2 comments

Events can come through out of order due to use of async in forEach. Iterations of the forEach loop execute concurrently which allows a later call to complete before an earlier call.

https://github.com/pozil/pub-sub-api-node-client/blob/da3be87e9511f95244830a583205cc55e5e7ac66/src/client.js#L327

brodymccrone4 avatar Jul 10 '24 23:07 brodymccrone4

Hi @brodymccrone4, thanks for reporting this. The problem is not so much the async statement in the loop but the fact that we rely on an EventEmitter that fires events and this introduces some asynchronicity. I need to look into this.

pozil avatar Jul 17 '24 15:07 pozil

I've released a new version thanks to @eltoroit PR. This should reduce the frequency of the issue.

Next step to fully remove asynchronicity from the event processing chain will be to remove the EventEmitter from the architecture. This will require a major release. I'll keep this issue open in the meantime.

pozil avatar Sep 08 '24 13:09 pozil

I'm happy to share that I finally managed to release v5, a major version that addresses this issue by removing asynchronicity from the event processing chain 🎉

pozil avatar Oct 20 '24 21:10 pozil