Skip to content

Commit

Permalink
fix: Use isMaster instead of hello to support older instances (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattijauhiainen authored May 23, 2021
1 parent fc3f3e6 commit 6c9a465
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ export class Cluster {
const results = await Promise.all(this.#protocols.map((protocol) => {
return protocol.commandSingle(
"admin",
{ hello: 1 },
{ isMaster: 1 },
);
}));
const masterIndex = results.findIndex((result) => result.isWritablePrimary);
const masterIndex = results.findIndex((result) =>
result.isWritablePrimary || result.ismaster
);
if (masterIndex === -1) throw new Error(`Could not find a master node`);
this.#masterIndex = masterIndex;
}
Expand Down

0 comments on commit 6c9a465

Please sign in to comment.