Skip to content

Commit 27934a4

Browse files
committed
feat(MongoMemoryReplSet): change generic "instanceinfo missing" errors to "InstanceInfoError"
1 parent dbcd00a commit 27934a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,10 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
676676
(server) => server.instanceInfo?.instance.isInstancePrimary
677677
);
678678
assertion(!isNullOrUndefined(primary), new Error('No Primary found'));
679+
// this should be defined at this point, but is checked anyway (thanks to types)
679680
assertion(
680681
!isNullOrUndefined(primary.instanceInfo),
681-
new Error('Primary dosnt have "instanceInfo" defined') // TODO: change to "InstanceInfoError"
682+
new InstanceInfoError('_initReplSet authIsObject primary')
682683
);
683684

684685
await primary.createAuth(primary.instanceInfo);
@@ -764,8 +765,9 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
764765
new Promise<void>((res, rej) => {
765766
const instanceInfo = server.instanceInfo;
766767

768+
// this should be defined at this point, but is checked anyway (thanks to types)
767769
if (isNullOrUndefined(instanceInfo)) {
768-
return rej(new Error('_waitForPrimary - instanceInfo not present')); // TODO: change to "InstanceInfoError"
770+
return rej(new InstanceInfoError('_waitForPrimary Primary race'));
769771
}
770772

771773
instanceInfo.instance.once(MongoInstanceEvents.instancePrimary, res);

0 commit comments

Comments
 (0)