Closed alvaroinckot closed 1 year ago
A fix could be something like?
/**
* It's a debounced method to send INFO packets to remote nodes.
*/
localServiceChanged() {
if (!this.stopping) { // add this check before sending local node info
this.registry.discoverer.sendLocalNodeInfo();
}
}
EDIT: This snippet does fix the issue, but IDK exactly how to create an unit test case for that. If you guys give me the guidance, I can do it.
This would be really helpful 🚀
@alvaroinckot nice catch, please open a PR with your fix. Currently, there is no integration test for balancing logic, only unit tests. So for me, it's enough if you add a unit test for the fix and we can check manually with the repro code. Check this part of tests: https://github.com/moleculerjs/moleculer/blob/master/test/unit/service-broker.spec.js#L1660
@icebob I just created the PR #1186. Thank you!
:stop_sign: Do you want to ask a question ?
Please head to the Discord chat
Prerequisites
Please answer the following questions for yourself before submitting an issue.
Current Behavior
Using NATS, if a
ServiceBroker
with internal services enabled gets stopped during a service change process, it proceeds with theunsubscribeFromBalancedCommands
and fails as the NATS client was already flushed in the stop process.It is very likely to happen during integration tests or when scaling up and down nodes.
Expected Behavior
When the
ServiceBroker
is stopped, the bounced service change process should be interrupted.Failure Information
I was able to reproduce it only with NATS, and line of code in the
service-broker.js
file causing it should be:this.localServiceChanged = _.debounce(() => origLocalServiceChanged.call(this), 1000);
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
Reproduce code snippet
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Failure Logs