Skip to content

Commit b2d63d9

Browse files
committed
revert: "fix(MongoMemoryReplSet): add extra fail-save to the timout"
This reverts commit e2c5511.
1 parent 0878d3a commit b2d63d9

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,6 @@ export class MongoMemoryReplSet extends EventEmitter {
589589
*/
590590
protected async _waitForPrimary(timeout: number = 30000): Promise<void> {
591591
let timeoutId: NodeJS.Timeout | undefined;
592-
// This is needed, because somehow, the timeout dosnt get always cleared (in time?), so this is an extra fail-save
593-
// https://github.com/nodkz/mongodb-memory-server/issues/431
594-
let foundPrimary = false;
595592

596593
await Promise.race([
597594
...this.servers.map(
@@ -611,21 +608,13 @@ export class MongoMemoryReplSet extends EventEmitter {
611608
}
612609
})
613610
),
614-
new Promise<void>((res, rej) => {
611+
new Promise((_res, rej) => {
615612
timeoutId = setTimeout(() => {
616-
if (foundPrimary) {
617-
log('_waitForPrimary: timeout didnt get cleared, but primary found');
618-
619-
return res();
620-
}
621-
622-
return rej(new Error(`Timed out after ${timeout}ms while waiting for an Primary`));
613+
rej(new Error(`Timed out after ${timeout}ms while waiting for an Primary`));
623614
}, timeout);
624615
}),
625616
]);
626617

627-
foundPrimary = true;
628-
629618
if (!isNullOrUndefined(timeoutId)) {
630619
clearTimeout(timeoutId);
631620
}

0 commit comments

Comments
 (0)