Skip to content

(NODEJS) MongoClient close method seems to be closing the database instead of just closing the client connection  #1225

@tiaferre

Description

@tiaferre

ArcadeDB Version:

ArcadeDB Server v23.9.1-SNAPSHOT

OS and JDK Version:

Linux 5.10.16.3-microsoft-standard-WSL2 - OpenJDK 64-Bit Server VM 11.0.20

Expected behavior

NodeJS client.close() should not close the database

Actual behavior

database is closing
Even without the close() method, when executing the process dies and the database closes. The close() ends up being called and the database ends up closing, which means that other processes won't be able to call and execute commands to this database.

Steps to reproduce

When running this code:

const connectionString = "mongodb://localhost:27017";
const client = new MongoClient(connectionString);

const databaseMy = "heroes";
const collectionMy = "Heros";
await client
.connect()
.then(async function (db) {
await db.db(databaseMy).collection(collectionMy).insertOne({ name: "a", lastName: "aa" }, { forceServerObjectId: true });
await db.db(databaseMy).collection(collectionMy).insertOne({ name: "b", lastName: "bb" }, { forceServerObjectId: true });
await client.close();
})
.catch(async (err) => {
logger.error(err);
});
await client
.connect()
.then(async function (db) {
await db.db(databaseMy).collection(collectionMy).insertOne({ name: "c", lastName: "cc" }, { forceServerObjectId: true });
await db.db(databaseMy).collection(collectionMy).insertOne({ name: "d", lastName: "dd" }, { forceServerObjectId: true });
await client.close();
})
.catch(async (err) => {
logger.error(err);
});

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions