-
-
Notifications
You must be signed in to change notification settings - Fork 188
Closed
Labels
bugreleasedPull Request released | Issue is fixedPull Request released | Issue is fixedreleased on @beta
Description
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
Labels
bugreleasedPull Request released | Issue is fixedPull Request released | Issue is fixedreleased on @beta