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: don't use broker id from client object #110

Closed
wants to merge 2 commits into from

Conversation

bmeverett
Copy link

The delWill method is accessing the brokerId from client, which is undefined and therefore causing the key to not be deleted. This updates delWill to get the broker id from this.broker.id similar to how getWill is doing it.

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

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

Could you add a test that covers this?

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

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

After double checking this and also https://github.com/moscajs/aedes-persistence-mongodb/blob/master/persistence.js#L585

I remember that the reason why we use client brokerId is that in case of a cluster usage the client brokerId can be different from this.broker.id. So this is wrong I'm sorry, we should detect the reason why the brokerId is not set on your case

I have a feel that the test you added would pass even without the change on persistence? There was already a test that covers the put/del/getWill here: https://github.com/moscajs/aedes-persistence/blob/main/abstract.js#L1458

@bmeverett
Copy link
Author

@robertsLando thanks for the feedback. The test does fail without my change, because I'm not setting the broker id explicitly in my test so that causes it to fail. The test you referenced is explicitly setting the brokerId before calling delWill

I can investigate my use case further to determine where the issue is. I would expect all the methods getWil, putwil and delWill should all be getting the key the same way or maybe I'm misunderstanding

@bmeverett
Copy link
Author

So after investigating a little further, I think the issue I'm trying to solve is more related to how aedes and the persistence work. What I was trying to solve, was when a client connects to aedes with a LWT, it is stored in redis. However, if that client disconnects gracefully then we don't need to send the will message. But that also means that the key is never cleaned up from redis. So based on this code in aedes it may be an issue with aedes, or just how it's supposed to function.

@robertsLando
Copy link
Member

By checking that code the issue seems to be on aedes, when the will is present we should always delete it after the disconnection

@bmeverett
Copy link
Author

I'm going to close this then. I put up a PR in aedes with the fix

@bmeverett bmeverett closed this Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants