typegoose / mongodb-memory-server

Manage & spin up mongodb server binaries with zero(or slight) configuration for tests.
https://typegoose.github.io/mongodb-memory-server/
MIT License
2.61k stars 187 forks source link

MacOS Sequoia 15.0 "instanceInfo" is not defined #888

Closed lusqua closed 1 month ago

lusqua commented 2 months ago

Versions

package: mongo-memory-server-global

What is the Problem?

MongoMS:MongoMemoryServer Mongo[unknown]: stop: "instanceInfo" is not defined (never ran?) +0ms
Error: Instance failed to start within 10000ms
    at Timeout.<anonymous> (/Users/lucasaguiar/Projects/woovi/woovi/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:148:29)
    at listOnTimeout (node:internal/timers:581:17)
    at process.processTimers (node:internal/timers:519:7)

Debug Output

Debug Output ```bash MONGOMS_DEBUG=1 pnpm jest packages/service-main/src/modules/integration/mutations/metaPixel/__tests__/IntegrationEditMetaPixel.spec.ts swc-jest Determining test suites to run... MongoMS:ResolveConfig Debug Mode Enabled, through Environment Variable +0ms MongoMS:ResolveConfig findPackageJson: Found package.json at "/Users/lucasaguiar/Projects/woovi/woovi/package.json" +0ms MongoMS:MongoMemoryServer create: Called .create() method +0ms MongoMS:MongoMemoryServer Mongo[unknown]: start: Called .start() method +0ms MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Called MongoMemoryServer._startUpInstance() method +0ms MongoMS:MongoMemoryServer Mongo[unknown]: getStartOptions: forceSamePort: false +0ms MongoMS:DryMongoBinary generateOptions +0ms MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms MongoMS:DryMongoBinary generatePaths { version: '6.0.16', downloadDir: '', os: { os: 'darwin' }, platform: 'darwin', arch: 'arm64', systemBinary: '' } +0ms MongoMS:DryMongoBinary getBinaryName +1ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary generateDownloadPath: Paths: { homeCache: '/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16', modulesCache: '/Users/lucasaguiar/Projects/woovi/woovi/node_modules/.cache/mongodb-memory-server/mongod-arm64-darwin-6.0.16', relative: '/Users/lucasaguiar/Projects/woovi/woovi/mongodb-binaries/mongod-arm64-darwin-6.0.16', resolveConfig: '' } +0ms (node:21715) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) MongoMS:DryMongoBinary generateDownloadPath: Found binary in homeCache: "/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16" +1ms MongoMS:GetPort EXP_NET0LISTEN false +0ms MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Creating new MongoDB instance with options: { instance: { port: 33082, dbName: '', ip: '127.0.0.1', storageEngine: 'ephemeralForTest', replSet: undefined, dbPath: '/var/folders/sh/2k7php4119sfy_g51zlxld100000gn/T/mongo-mem-NRbgrZ', tmpDir: '/var/folders/sh/2k7php4119sfy_g51zlxld100000gn/T/mongo-mem-NRbgrZ', keyfileLocation: undefined, launchTimeout: undefined, args: undefined, auth: false }, binary: { systemBinary: undefined, skipMD5: true }, spawn: undefined } +5ms MongoMS:MongoInstance create: Called .create() method +0ms MongoMS:MongoInstance Mongo[33082]: start +0ms MongoMS:MongoBinary getPath +0ms MongoMS:DryMongoBinary generateOptions +2ms MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms MongoMS:DryMongoBinary generatePaths { version: '6.0.16', downloadDir: '', os: { os: 'darwin' }, platform: 'darwin', arch: 'arm64', systemBinary: '' } +0ms MongoMS:DryMongoBinary getBinaryName +1ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary generateDownloadPath: Paths: { homeCache: '/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16', modulesCache: '/Users/lucasaguiar/Projects/woovi/woovi/node_modules/.cache/mongodb-memory-server/mongod-arm64-darwin-6.0.16', relative: '/Users/lucasaguiar/Projects/woovi/woovi/mongodb-binaries/mongod-arm64-darwin-6.0.16', resolveConfig: '' } +0ms MongoMS:DryMongoBinary generateDownloadPath: Found binary in homeCache: "/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16" +0ms MongoMS:MongoBinary getPath: MongoBinary options: { "version": "6.0.16", "downloadDir": "/Users/lucasaguiar/.cache/mongodb-binaries", "os": { "os": "darwin" }, "platform": "darwin", "arch": "arm64", "systemBinary": "", "checkMD5": true } +1ms MongoMS:DryMongoBinary locateBinary: Trying to locate Binary for version "6.0.16" +0ms MongoMS:DryMongoBinary generateOptions +0ms MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms MongoMS:DryMongoBinary generatePaths { version: '6.0.16', downloadDir: '/Users/lucasaguiar/.cache/mongodb-binaries', os: { os: 'darwin' }, platform: 'darwin', arch: 'arm64', systemBinary: '' } +0ms MongoMS:DryMongoBinary getBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary generateDownloadPath: Paths: { homeCache: '/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16', modulesCache: '/Users/lucasaguiar/Projects/woovi/woovi/node_modules/.cache/mongodb-memory-server/mongod-arm64-darwin-6.0.16', relative: '/Users/lucasaguiar/Projects/woovi/woovi/mongodb-binaries/mongod-arm64-darwin-6.0.16', resolveConfig: '/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16' } +0ms MongoMS:DryMongoBinary generateDownloadPath: Found binary in resolveConfig (DOWNLOAD_DIR): "/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16" +0ms MongoMS:DryMongoBinary locateBinary: running generateDownloadPath +0ms MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms MongoMS:DryMongoBinary generatePaths { version: '6.0.16', downloadDir: '/Users/lucasaguiar/.cache/mongodb-binaries', os: { os: 'darwin' }, platform: 'darwin', arch: 'arm64', systemBinary: '' } +0ms MongoMS:DryMongoBinary getBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary combineBinaryName +0ms MongoMS:DryMongoBinary generateDownloadPath: Paths: { homeCache: '/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16', modulesCache: '/Users/lucasaguiar/Projects/woovi/woovi/node_modules/.cache/mongodb-memory-server/mongod-arm64-darwin-6.0.16', relative: '/Users/lucasaguiar/Projects/woovi/woovi/mongodb-binaries/mongod-arm64-darwin-6.0.16', resolveConfig: '/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16' } +0ms MongoMS:DryMongoBinary generateDownloadPath: Found binary in resolveConfig (DOWNLOAD_DIR): "/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16" +1ms MongoMS:DryMongoBinary locateBinary: found binary at "/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16" +0ms MongoMS:MongoBinary getPath: Mongod binary path: "/Users/lucasaguiar/.cache/mongodb-binaries/mongod-arm64-darwin-6.0.16" +1ms MongoMS:MongoInstance Mongo[33082]: start: Starting Processes +2ms MongoMS:MongoInstance Mongo[33082]: _launchMongod: Launching Mongod Process +0ms MongoMS:MongoInstance Mongo[33082]: prepareCommandArgs +0ms MongoMS:MongoInstance Mongo[33082]: prepareCommandArgs: final argument array:["--port","33082","--dbpath","/var/folders/sh/2k7php4119sfy_g51zlxld100000gn/T/mongo-mem-NRbgrZ","--storageEngine","ephemeralForTest","--bind_ip","127.0.0.1","--noauth"] +0ms MongoMS:MongoInstance Mongo[33082]: _launchKiller: Launching Killer Process (parent: 21715, child: 26761) +1ms MongoMS:MongoInstance Mongo[33082]: constructor: Instance has thrown an Error: Error: Instance failed to start within 10000ms +10s MongoMS:MongoInstance Mongo[33082]: stop +0ms MongoMS:utils Mongo[33082] killProcess: mongodProcess: sending "SIGINT" +0ms MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance threw a Error: GenericMMSError: Instance failed to start within 10000ms at Timeout. (/Users/lucasaguiar/Projects/woovi/woovi/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:148:29) at listOnTimeout (node:internal/timers:581:17) at process.processTimers (node:internal/timers:519:7) +10s MongoMS:MongoMemoryServer Mongo[unknown]: stop: Called .stop() method +2ms MongoMS:MongoMemoryServer Mongo[unknown]: stop: "instanceInfo" is not defined (never ran?) +0ms Error: Instance failed to start within 10000ms at Timeout. (/Users/lucasaguiar/Projects/woovi/woovi/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:148:29) at listOnTimeout (node:internal/timers:581:17) at process.processTimers (node:internal/timers:519:7) ```

Do you know why it happenes?

MacOS update ( ? )

hasezoey commented 2 months ago

i dont think there is anything we can do about this, there is no error (aside from the launch timeout) and no logs from the mongod process, indicating that the system is not properly executing it, or there was a change in the macos update that broke mongodb.

maybe try:

lusqua commented 2 months ago

I was able to resolve my problem by increasing the default timeout to 100 seconds. I believe this adjustment is necessary due to recent changes in the operating system that affect the default runtime.

What I Did

I manually changed the launchTimeout default value in the following file:

/node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:148

My Attempt to Configure launchTimeout via the Create Function

I tried to set the launchTimeout using the create function configuration as shown below:

const mongod = await MongoMemoryServer.create({
  binary: {
    systemBinary: process.env.MONGODB_BINARY,
    checkMD5: false,
  },
  instance: {
    launchTimeout: 100_000, // 100 seconds timeout
  },
});

I've did something wrong on the config? However, this configuration did not work as expected. The launchTimeout remained undefined in the logs.

Debugging Steps

I added a debug line to inspect the timeout configuration, but it didn't reflect the changes I made:

debug command after

node_modules/mongodb-memory-server-core/lib/util/MongoInstance.js:55
this.debug('constructor: Instance Options', this.instanceOpts);
MongoMS:MongoInstance Mongo[16546]: constructor: config Options {
  instance: {
    port: 16546,
    dbName: '',
    ip: '127.0.0.1',
    storageEngine: 'ephemeralForTest',
    replSet: undefined,
    dbPath: '/var/folders/sh/2k7php4119sfy_g51zlxld100000gn/T/mongo-mem-eQSWP2',
    tmpDir: '/var/folders/sh/2k7php4119sfy_g51zlxld100000gn/T/mongo-mem-eQSWP2',
    keyfileLocation: undefined,
    launchTimeout: undefined,
    args: undefined,
    auth: false
  },
  binary: {
    systemBinary: '/Users/lucasaguiar/.cache/mongodb-binaries/mongodb-8.0.0',
    skipMD5: true
  },
  spawn: undefined
} +1ms

As you can see, the launchTimeout remains undefined despite my configuration attempt.

Questions

  1. How can I properly change the launchTimeout using the create function configuration?

  2. Is there an alternative method to set the launchTimeout without modifying the source file directly?

Any assistance or guidance on how to correctly configure the launchTimeout would be greatly appreciated. Thank you!

hasezoey commented 2 months ago

My Attempt to Configure launchTimeout via the Create Function

that is the way it should work, and from my current attempts, it also gets properly passed down (at least in 10.0.1 and 9.4.1)

my test:

(Note: i did it via the node-repl)

Is there an alternative method to set the launchTimeout without modifying the source file directly?

like i said above, it should have worked, and no, the above (ie configure in start / create) is the only way (aside from manually setting the opts after construction but before starting)

PS: i just noticed your are on MMS 9.x consider upgrading 10.x

github-actions[bot] commented 1 month ago

Marking the Issue as stale, it will be closed in 7 days if no more activity is seen