File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
packages/mongodb-memory-server-core/src/util Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -542,11 +542,7 @@ export class MongoInstance extends EventEmitter implements ManagerBase {
542542 if ( / \* \* \* a b o r t i n g a f t e r / i. test ( line ) ) {
543543 this . emit ( MongoInstanceEvents . instanceError , 'Mongod internal error' ) ;
544544 }
545- if ( / t r a n s i t i o n t o p r i m a r y c o m p l e t e ; d a t a b a s e w r i t e s a r e n o w p e r m i t t e d / i. test ( line ) ) {
546- this . isInstancePrimary = true ;
547- this . debug ( 'stdoutHandler: emitting "instancePrimary"' ) ;
548- this . emit ( MongoInstanceEvents . instancePrimary ) ;
549- }
545+ // this case needs to be infront of "transition to primary complete", otherwise it might reset "isInstancePrimary" to "false"
550546 if ( / t r a n s i t i o n t o \w + f r o m \w + / i. test ( line ) ) {
551547 const state = / t r a n s i t i o n t o ( \w + ) f r o m \w + / i. exec ( line ) ?. [ 1 ] ?? 'UNKNOWN' ;
552548 this . emit ( MongoInstanceEvents . instanceReplState , state ) ;
@@ -555,6 +551,11 @@ export class MongoInstance extends EventEmitter implements ManagerBase {
555551 this . isInstancePrimary = false ;
556552 }
557553 }
554+ if ( / t r a n s i t i o n t o p r i m a r y c o m p l e t e ; d a t a b a s e w r i t e s a r e n o w p e r m i t t e d / i. test ( line ) ) {
555+ this . isInstancePrimary = true ;
556+ this . debug ( 'stdoutHandler: emitting "instancePrimary"' ) ;
557+ this . emit ( MongoInstanceEvents . instancePrimary ) ;
558+ }
558559 }
559560}
560561
You can’t perform that action at this time.
0 commit comments