Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Node forking will include any --import from the original command #912

Copy link
Copy link
Closed
@hasezoey

Description

@hasezoey
Issue body actions

Versions

  • NodeJS: 23.3.0
  • mongodb-memory-server-*: 9.x, 10.x, 10.1.3
  • mongodb(the binary version): not relevant, quickest to notice is 7.0.14
  • mongodb(the js package): not relevant
  • system: linux, but likely others

package: mongo-memory-server-core

What is the Problem?

It seems like when we do child_process.fork now, it implies --import PRELOAD if the original process has been started with --import, like in the following example.
This causes the PRELOAD to be re-executed upon forking to the killer_script, causing a infinite loop of starting and never cleaning-up extra mongo servers.

see #907 (comment)

Code Example

// setup.js
const t = require("node:test");
const { MongoMemoryServer } = require("mongodb-memory-server-core");

let dbServer;

module.exports.connect = async () => {
  dbServer = await MongoMemoryServer.create();
};

module.exports.closeDatabase = async () => {
  await new Promise((res) => {
    setTimeout(res, 1000 * 10);
  })
  await dbServer.stop({ doCleanup: true });
};

t.before(async () => {
  await module.exports.connect();
});

t.after(async () => {
  await module.exports.closeDatabase();
});

// a.test.js
const t = require("node:test");

t.describe("name", () => {
  t.it("test", () => {
    1+1
  });
});

Execute with:

node --test --import ./setup.js

Debug Output

no output by default as we disable stdio for the forked process

Do you know why it happenes?

Yes, as described above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.