[DOCS-14237] maxTimeMS is not supported as an option to MongoClient constructor Created: 10/Feb/21  Updated: 04/Jan/23  Resolved: 14/Jun/21

Status: Closed
Project: Documentation
Component/s: drivers
Affects Version/s: 3.6.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Rajat Malhotra Assignee: Kailie Yuan
Resolution: Done Votes: 0
Labels: node-driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 2 years, 31 weeks ago
Epic Link: DOCSP-7596
Story Points: 1

 Description   

Hi Team

Here https://docs.mongodb.com/drivers/node/faq/#how-can-i-prevent-long-running-operations-from-slowing-down-the-server- it is mentioned that one can pass maxTimeMS option setting in MongoClient constructor to apply this to all the operations called by the client but on using this option it is showing this message:

the options [maxTimeMS] is not supported

 
Script:

const mongodb = require('mongodb');
const { MongoClient } = mongodb;
const client = new MongoClient('mongodb://localhost:27017/db', {
    maxTimeMS: 1000,
    useUnifiedTopology: true
});
client.connect().then(() => {
    console.log('connected');
})
.catch(err => console.error('connection err:', err))
.finally(() => {
    client.close();
});

Mongodb driver version: 3.6.4
NodeJs version: 12.6.1
Platform: MacOS Big Sur

 



 Comments   
Comment by Githook User [ 07/Jul/21 ]

Author:

{'name': 'kyuan-mongodb', 'email': '78768401+kyuan-mongodb@users.noreply.github.com', 'username': 'kyuan-mongodb'}

Message: DOCS-14237 max time ms note (#181)

Comment by Githook User [ 13/Jun/21 ]

Author:

{'name': 'kyuan-mongodb', 'email': '78768401+kyuan-mongodb@users.noreply.github.com', 'username': 'kyuan-mongodb'}

Message: DOCS-14237 max time ms note (#182)

Comment by Githook User [ 13/Jun/21 ]

Author:

{'name': 'kyuan-mongodb', 'email': '78768401+kyuan-mongodb@users.noreply.github.com', 'username': 'kyuan-mongodb'}

Message: DOCS-14237 max time ms note (#181)

Comment by Kailie Yuan [ 11/Jun/21 ]

master: https://github.com/mongodb/docs-node/pull/181 
v3.6: https://github.com/mongodb/docs-node/pull/182

Comment by Rajat Malhotra [ 19/Feb/21 ]

Hi @Alexander, thanks for the update. I'm aware of the command specific operation but I was looking for passing at client level so that I won't have to pass it to each query. If we can add this option in future release, then it would be really great.

Comment by Alexander Golin (Inactive) [ 18/Feb/21 ]

Hi rajat.malhotra@vedantu.com, this appears to be an issue with our documentation - While the example specifies passing in maxTimeMS to the client constructor, it should instead be set as an option to certain specific commands. Please take a look at our find documentation for an example of maxTimeMS' usage: https://mongodb.github.io/node-mongodb-native/3.6/api/Collection.html#find

We are sending this ticket to the docs team to update the example.

Generated at Thu Feb 08 08:09:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.