Skip to content

Commit a9f42ea

Browse files
committed
fix(MongoInstance): closeHandler: also log the exit signal
1 parent aa75e42 commit a9f42ea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/mongodb-memory-server-core/src/util/MongoInstance.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,16 @@ export class MongoInstance extends EventEmitter implements ManagerBase {
443443
* @param code The Exit code to handle
444444
* @fires MongoInstance#instanceClosed
445445
*/
446-
closeHandler(code: number): void {
446+
closeHandler(code: number, signal: string): void {
447447
// check if the platform is windows, if yes check if the code is not "12" or "0" otherwise just check code is not "0"
448448
// because for mongodb any event on windows (like SIGINT / SIGTERM) will result in an code 12
449449
// https://docs.mongodb.com/manual/reference/exit-codes/#12
450450
if ((process.platform === 'win32' && code != 12 && code != 0) || code != 0) {
451451
this.debug('closeHandler: Mongod instance closed with an non-0 (or non 12 on windows) code!');
452452
}
453453

454-
this.debug(`closeHandler: ${code}`);
455-
this.emit(MongoInstanceEvents.instanceClosed, code);
454+
this.debug(`closeHandler: "${code}" "${signal}"`);
455+
this.emit(MongoInstanceEvents.instanceClosed, code, signal);
456456
}
457457

458458
/**

packages/mongodb-memory-server-core/src/util/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function assertion(cond: unknown, error?: Error): asserts cond {
7272
export async function killProcess(
7373
childprocess: ChildProcess,
7474
name: string,
75-
mongodPort: number | undefined
75+
mongodPort?: number
7676
): Promise<void> {
7777
function ilog(msg: string) {
7878
log(`Mongo[${mongodPort || 'unknown'}] killProcess: ${msg}`);

0 commit comments

Comments
 (0)