Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A systemerror occurs when starting mongode-memory-server. #770

Closed
akasataikisiti opened this issue Jun 16, 2023 · 2 comments
Closed

A systemerror occurs when starting mongode-memory-server. #770

akasataikisiti opened this issue Jun 16, 2023 · 2 comments
Labels

Comments

@akasataikisiti
Copy link

akasataikisiti commented Jun 16, 2023

Versions

  • OS: macOS 13.4 22F66 arm64
  • MongoDB Memory Server version: 8.13.0
  • Mongoose version: 7.2.2
  • Node.js version: 18.13.0
  • jest: ^29.5.0

What is the Problem?

System error when trying to run tests using mongode-memory-server.

Code Example

import { MongoMemoryServer } from "mongodb-memory-server";
import mongoose from "mongoose";
import { app } from "../app";

let mongo: any;

beforeAll(async () => {
  const mongo = await MongoMemoryServer.create();
  const mongoUri = mongo.getUri();

  await mongoose.connect(mongoUri, {});
});

beforeEach(async () => {
  const collections = await mongoose.connection.db.collections();

  for (let collection of collections) {
    await collection.deleteMany({});
  }
});

afterAll(async () => {
  if (mongo) {
    await mongo.stop();
  }
  await mongoose.connection.close();
});

Debug Output

console.warn
  Starting the MongoMemoryServer Instance failed, enable debug log for more information. Error:
   Error: spawn Unknown system error -86
      at ChildProcess.spawn (node:internal/child_process:413:11)
      at spawn (node:child_process:757:9)
      at MongoInstance._launchMongod (/Users/mac_a/work/for_Learn/ticketing/auth/node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:474:31)
      at MongoInstance.<anonymous> (/Users/mac_a/work/for_Learn/ticketing/auth/node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:376:31)
      at Generator.next (<anonymous>)
      at fulfilled (/Users/mac_a/work/for_Learn/ticketing/auth/node_modules/tslib/tslib.js:164:62) {
    errno: -86,
    code: 'Unknown system error -86',
    syscall: 'spawn'
  }

    at MongoMemoryServer.<anonymous> (node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:293:17)
    at node_modules/tslib/tslib.js:167:75
    at __awaiter (node_modules/tslib/tslib.js:163:16)
    at node_modules/mongodb-memory-server-core/src/MongoMemoryServer.ts:284:68

Do you know why it happenes?

no

Additional Information

I Read the past issue, and run the command export MONGOMS_ARCH=x64 in the terminal
and then running the test. But didn't work either.

Thank you.

@hasezoey
Copy link
Member

hasezoey commented Jun 16, 2023

i dont quite know what -86 is, but have you verified:

  • that rosetta is running & working
  • have you already tried a earlier version like 4.0.28 or some 4.4. version? (if that is the case, you are running into the AVX problem)
  • have you tried a newer version like 6.0.4 without the MONGOMS_ARCH variable (that is the version since arm64 builds for mac exist)

also please provide full debug log while applying MONGOMS_ARCH

reference for the AVX problem: #710 (comment) (mongodb 5.0 and higher require AVX, which docker does not have and seemingly rosetta does translate)

@hasezoey hasezoey added question and removed bug labels Jun 16, 2023
@akasataikisiti
Copy link
Author

Thank you for your reply.
I solved the problem by specifying the mongodb download url.

I was able to successfully run the test by running the following command in the terminal.
export MONGOMS_DOWNLOAD_URL=https://fastdl.mongodb.org/osx/mongodb-macos-arm64-6.0.5.tgz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants