Skip to content

Commit

Permalink
fix: wrong object passed to learNode
Browse files Browse the repository at this point in the history
Caused timestap to be lost
  • Loading branch information
fredriklindberg committed Jan 6, 2024
1 parent 37cd4bd commit fd757fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cluster/cluster-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class ClusterManager {

let csnode: ClusterServiceNode | undefined = this._nodes[cnode.id];
if (event == 'cluster:heartbeat' || csnode == undefined) {
csnode = this._learnNode(node);
csnode = this._learnNode(cnode);
}

if (csnode == undefined) {
Expand Down
16 changes: 16 additions & 0 deletions test/unit/cluster/test_cluster-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,22 @@ describe('cluster service', () => {
await bus.destroy();
});

it(`getNodes() returns all nodes`, async () => {
const bus = new EventBus();

await clock.tickAsync(1);
await publish(bus, 'foo', {data: 42});
await clock.tickAsync(1);

const nodes = ClusterManager.getNodes();
assert(nodes.length == 2, "unexpected number of nodes");

assert(nodes[0].last_ts == 2);
assert(nodes[1].ip == "127.0.0.127");
assert(nodes[1].last_ts == 1);

await bus.destroy();
});
});

});

0 comments on commit fd757fe

Please sign in to comment.