Fix/update inventory on nacks#2071
Conversation
89bf54e to
9a2ca06
Compare
| const latency = (Date.now() - startTime) / 1000; | ||
| this._latencies.add(latency); | ||
|
|
||
| this._inventory.remove(message); |
There was a problem hiding this comment.
I think we wouldn't want to remove it in the case of a legit modack, just in the case of nack. But yeah, this clearly seems like an oversight.
There was a problem hiding this comment.
The problem with not removing the message from the inventory is that the inventory will remain full forever in case of many nacks. If my maxMessages is 5 and I had 5 nacks, the inventory will remain full and the subscription will never receive messages again.
This is strange and hidden behavior. Some people have lost a little of their sanity trying to understand what was going on and why their subscription never received messages again.
There was a problem hiding this comment.
Yeah. When the user calls ack or nack, they're clearing asking for some kind of non-leasing behaviour, so removing it from the inventory in that case makes sense. For the (internal) modack case, though, we don't want to remove it. A nack is just a modack with a time of 0, so probably just adding a check there before removing it would be fine.
There was a problem hiding this comment.
Ok, but excuse me, I'm not sure I understood correctly. If the modnack is a nack with a time of 0, what check do you think we should perform before clearing the inventory?
Fixes #2070 🦕