Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix handling of resending messages during a disconnect. #178

Merged
merged 2 commits into from
Aug 26, 2021

Conversation

jwalton
Copy link
Owner

@jwalton jwalton commented Aug 26, 2021

The unit tests for this had a fatal flaw - they assumed that if the
connection dropped, we'd get nothing back for any in-flight messages.
This isn't true, though - we'd actually get back an error from amqplib
when the underlying connection fails. This fixes the tests to reflect
this. If we rely on amqplib to reject such messages, then moving all
messages from _unconfirmedMessages to _messages on a
reconnect now becomes superfluous.

I also reworked _publishQueuedMessages() to be more synchronous.
As it stood, I had to add a lot of pointless delays in my tests to make
sure that the then after publishing a message had time to run.

fix #152

The unit tests for this had a fatal flaw - they assumed that if the
connection dropped, we'd get nothing back for any in-flight messages.
This isn't true, though - we'd actually get back an error from amqplib
when the underlying connection fails.  This fixes the tests to reflect
this.  If we rely on amqplib to reject such messages, then moving all
messages from _unconfirmedMessages to _messages on a
reconnect now becomes superfluous.

I also reworked `_publishQueuedMessages()` to be more synchronous.
As it stood, I had to add a lot of pointless delays in my tests to make
sure that the `then` after publishing a message had time to run.

fix #152
@jwalton
Copy link
Owner Author

jwalton commented Aug 26, 2021

@luddd3 could I bother you for a quick review of this please? :)

Copy link

@fitzhavey fitzhavey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'm not sure I know enough about the repo to fully understand all the changes here.

Can't see any obvious mistakes, thanks for the fix!

@jwalton jwalton merged commit b0958fe into master Aug 26, 2021
@jwalton jwalton deleted the fix-handling-disconnect-resends branch August 26, 2021 16:17
@jwalton
Copy link
Owner Author

jwalton commented Aug 26, 2021

🎉 This PR is included in version 3.5.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@luddd3
Copy link
Collaborator

luddd3 commented Aug 26, 2021

I also think it looks fine. I'll do some testing with drain, etc. tomorrow. I'm currently working on consumer reconnects.

@luddd3
Copy link
Collaborator

luddd3 commented Aug 27, 2021

Worked fine in my tests at least =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing unconfirmed message always results in an error
3 participants