Events out of order
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
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.
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.
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 🎉