Skip to content

Commit 2c54e1f

Browse files
committed
fix(errors::UnexpectedCloseError): add extra message on SIGILL
re #693 re #692 re #687
1 parent fbd0747 commit 2c54e1f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,19 @@ describe('MongodbInstance', () => {
341341
}
342342
});
343343

344+
it('"closeHandler" should emit "instanceError" with extra information on "SIGILL"', () => {
345+
// test SIGILL
346+
mongod.closeHandler(null, 'SIGILL');
347+
348+
expect(events.size).toEqual(2);
349+
expect(events.get(MongoInstanceEvents.instanceClosed)).toEqual([null, 'SIGILL']);
350+
351+
const event = events.get(MongoInstanceEvents.instanceError)?.[0];
352+
expect(event).toBeInstanceOf(UnexpectedCloseError);
353+
assertIsError(event); // has to be used, because there is not typeguard from "expect(variable).toBeInstanceOf"
354+
expect(event.message).toMatchSnapshot();
355+
});
356+
344357
it('"closeHandler" should emit "instanceError" with non-0 or non-12 code', () => {
345358
// test code non-0
346359
{

packages/mongodb-memory-server-core/src/util/__tests__/__snapshots__/MongoInstance.test.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ exports[`MongodbInstance prepareCommandArgs should throw an error if no port is
88

99
exports[`MongodbInstance test events "closeHandler" should emit "instanceClosed" 1`] = `"Instance closed unexpectedly with code \\"null\\" and signal \\"SIG\\""`;
1010

11+
exports[`MongodbInstance test events "closeHandler" should emit "instanceError" with extra information on "SIGILL" 1`] = `
12+
"Instance closed unexpectedly with code \\"null\\" and signal \\"SIGILL\\"
13+
The Process Exited with SIGILL, which mean illegal instruction, which is commonly thrown in mongodb 5.0+ when not having AVX available on the CPU"
14+
`;
15+
1116
exports[`MongodbInstance test events "closeHandler" should emit "instanceError" with non-0 or non-12 code 1`] = `"Instance closed unexpectedly with code \\"1\\" and signal \\"null\\""`;
1217

1318
exports[`MongodbInstance test events "closeHandler" should emit "instanceError" with non-0 or non-12 code 2`] = `"Instance closed unexpectedly with code \\"null\\" and signal \\"SIG\\""`;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ export class UnexpectedCloseError extends Error {
178178
super();
179179

180180
this.message = `Instance closed unexpectedly with code "${code}" and signal "${signal}"`;
181+
182+
if (signal == 'SIGILL') {
183+
this.message +=
184+
'\nThe Process Exited with SIGILL, which mean illegal instruction, which is commonly thrown in mongodb 5.0+ when not having AVX available on the CPU';
185+
}
181186
}
182187
}
183188

0 commit comments

Comments
 (0)