Skip to content

Commit

Permalink
fix(MongoMemoryServer): add some extra context to -86 error on macos-arm
Browse files Browse the repository at this point in the history
re #674
  • Loading branch information
hasezoey committed Jul 13, 2022
1 parent 417d946 commit 1f0f045
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/mongodb-memory-server-core/src/MongoMemoryServer.ts
Expand Up @@ -19,6 +19,7 @@ import { promises as fspromises } from 'fs';
import { MongoClient } from 'mongodb';
import { lt } from 'semver';
import { EnsureInstanceError, StateError } from './util/errors';
import * as os from 'os';

const log = debug('MongoMS:MongoMemoryServer');

Expand Down Expand Up @@ -280,6 +281,13 @@ export class MongoMemoryServer extends EventEmitter implements ManagerAdvanced {
this.stateChange(MongoMemoryServerStates.starting);

await this._startUpInstance(forceSamePort).catch(async (err) => {
// add error information on macos-arm because "spawn Unknown system error -86" does not say much
if (err instanceof Error && err.message?.includes('spawn Unknown system error -86')) {
if (os.platform() === 'darwin' && os.arch() === 'arm64') {
err.message += err.message += ', Is Rosetta Installed and Setup correctly?';
}
}

if (!debug.enabled('MongoMS:MongoMemoryServer')) {
console.warn(
'Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:\n',
Expand Down

0 comments on commit 1f0f045

Please sign in to comment.