Skip to content

Commit 739c99a

Browse files
authored
fix(MongoInstance): 'Mongod shutting down' fires FAIL only if instance does not started (#130)
* test: fix CI with node-8 * test: fix CI node 8 * test: check ci node 8 * fix(MongoInstance): 'Mongod shutting down' fires FAIL only if instance does not started * fix: ts
1 parent 545d098 commit 739c99a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/util/MongoInstance.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default class MongodbInstance {
3434
killerProcess: ChildProcess;
3535
instanceReady: CallbackFn;
3636
instanceFailed: CallbackFn;
37+
isInstanceReady: boolean;
3738

3839
constructor(opts: MongodOps);
3940

src/util/MongoInstance.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default class MongodbInstance {
3737
killerProcess: ChildProcess;
3838
instanceReady: Function;
3939
instanceFailed: Function;
40+
isInstanceReady: boolean;
4041

4142
static run(opts: MongodOps): Promise<MongodbInstance> {
4243
const instance = new this(opts);
@@ -45,6 +46,7 @@ export default class MongodbInstance {
4546

4647
constructor(opts: MongodOps) {
4748
this.opts = opts;
49+
this.isInstanceReady = false;
4850

4951
if (this.opts.debug) {
5052
if (!this.opts.instance) this.opts.instance = {};
@@ -86,6 +88,7 @@ export default class MongodbInstance {
8688
async run(): Promise<MongodbInstance> {
8789
const launch = new Promise((resolve, reject) => {
8890
this.instanceReady = () => {
91+
this.isInstanceReady = true;
8992
this.debug('MongodbInstance: is ready!');
9093
resolve(this.childProcess);
9194
};
@@ -174,7 +177,10 @@ export default class MongodbInstance {
174177
} else if (/Data directory .*? not found/i.test(log)) {
175178
this.instanceFailed('Data directory not found');
176179
} else if (/shutting down with code/i.test(log)) {
177-
this.instanceFailed('Mongod shutting down');
180+
// if mongod started succesfully then no error on shutdown!
181+
if (!this.isInstanceReady) {
182+
this.instanceFailed('Mongod shutting down');
183+
}
178184
} else if (/\*\*\*aborting after/i.test(log)) {
179185
this.instanceFailed('Mongod internal error');
180186
}

0 commit comments

Comments
 (0)